From 5a6c928a7c83bca4b9f8b8d3303a3a2b74c12214 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 21 Jun 2019 17:34:06 -0400 Subject: [PATCH] Fixes #3279: Reset the PostgreSQL sequence for Tag and TaggedItem IDs --- CHANGELOG.md | 1 + netbox/extras/migrations/0023_fix_tag_sequences.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 netbox/extras/migrations/0023_fix_tag_sequences.py diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a4ec680..55d10190b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ v2.6.1 (FUTURE) ## Bug Fixes * [#3275](https://github.com/digitalocean/netbox/issues/3275) - Fix error when adding power outlets to a device type +* [#3279](https://github.com/digitalocean/netbox/issues/3279) - Reset the PostgreSQL sequence for Tag and TaggedItem IDs --- diff --git a/netbox/extras/migrations/0023_fix_tag_sequences.py b/netbox/extras/migrations/0023_fix_tag_sequences.py new file mode 100644 index 000000000..faef5aa96 --- /dev/null +++ b/netbox/extras/migrations/0023_fix_tag_sequences.py @@ -0,0 +1,14 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('extras', '0022_custom_links'), + ] + + operations = [ + # Update the last_value for tag Tag and TaggedItem ID sequences + migrations.RunSQL("SELECT setval('extras_tag_id_seq', (SELECT id FROM extras_tag ORDER BY id DESC LIMIT 1) + 1)"), + migrations.RunSQL("SELECT setval('extras_taggeditem_id_seq', (SELECT id FROM extras_taggeditem ORDER BY id DESC LIMIT 1) + 1)"), + ]