Ver Fonte

Fixes #3279: Reset the PostgreSQL sequence for Tag and TaggedItem IDs

Jeremy Stretch há 6 anos atrás
pai
commit
5a6c928a7c
2 ficheiros alterados com 15 adições e 0 exclusões
  1. 1 0
      CHANGELOG.md
  2. 14 0
      netbox/extras/migrations/0023_fix_tag_sequences.py

+ 1 - 0
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
 
 ---
 

+ 14 - 0
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)"),
+    ]