From 4a37d356944a8019c6feefd11f2ea9767ff0312f Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 1 Oct 2017 16:51:40 -0700 Subject: [PATCH] BUG: Reset collections id sequences --- .../migrations/0004_DATA_reset_sequences.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ccdb/collections_ccdb/migrations/0004_DATA_reset_sequences.py diff --git a/ccdb/collections_ccdb/migrations/0004_DATA_reset_sequences.py b/ccdb/collections_ccdb/migrations/0004_DATA_reset_sequences.py new file mode 100644 index 0000000..0bd8647 --- /dev/null +++ b/ccdb/collections_ccdb/migrations/0004_DATA_reset_sequences.py @@ -0,0 +1,62 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ('collections_ccdb', '0003_DATA_fix_display_names'), + ] + + operations = [ + migrations.RunSQL( + "SELECT setval('collections_ccdb_adfgpermit_id_seq', (" + "SELECT MAX(id)+1 FROM collections_ccdb_adfgpermit), false)", + + "SELECT setval('collections_ccdb_adfgpermit_id_seq', 1, false)" + ), + + migrations.RunSQL( + "SELECT setval('collections_ccdb_collection_id_seq', (" + "SELECT MAX(id)+1 FROM collections_ccdb_collection), false)", + + "SELECT setval('collections_ccdb_collection_id_seq', 1, false)" + ), + + migrations.RunSQL( + "SELECT setval('collections_ccdb_collectionmethod_id_seq', (" + "SELECT MAX(id)+1 FROM collections_ccdb_collectionmethod), false)", + + "SELECT setval('collections_ccdb_collectionmethod_id_seq', 1, " + "false)" + ), + + migrations.RunSQL( + "SELECT setval('collections_ccdb_collectiontrap_id_seq', (" + "SELECT MAX(id)+1 FROM collections_ccdb_collectiontrap), false)", + + "SELECT setval('collections_ccdb_collectiontrap_id_seq', 1, false)" + ), + + migrations.RunSQL( + "SELECT setval('collections_ccdb_collectiontype_id_seq', (" + "SELECT MAX(id)+1 FROM collections_ccdb_collectiontype), false)", + + "SELECT setval('collections_ccdb_collectiontype_id_seq', 1, false)" + ), + + migrations.RunSQL( + "SELECT setval('collections_ccdb_datasheetattachment_id_seq', (" + "SELECT MAX(id)+1 FROM collections_ccdb_datasheetattachment), " + "false)", + + "SELECT setval('collections_ccdb_datasheetattachment_id_seq', 1, " + "false)" + ), + + migrations.RunSQL( + "SELECT setval('collections_ccdb_flaw_id_seq', (" + "SELECT MAX(id)+1 FROM collections_ccdb_flaw), false)", + + "SELECT setval('collections_ccdb_flaw_id_seq', 1, false)" + ), + + ]