From 6f9601271f35c3ebd50c194aa40564792b0c5cee Mon Sep 17 00:00:00 2001 From: Neda Moeini <neda.moeini@geant.org> Date: Thu, 5 Dec 2024 12:43:25 +0100 Subject: [PATCH] Add the GA_ID and GS_ID sequence to manage automatic creation of GA and GS ids --- ...05_79192e72131c_add_gs_and_ga_sequences.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 gso/migrations/versions/2024-12-05_79192e72131c_add_gs_and_ga_sequences.py diff --git a/gso/migrations/versions/2024-12-05_79192e72131c_add_gs_and_ga_sequences.py b/gso/migrations/versions/2024-12-05_79192e72131c_add_gs_and_ga_sequences.py new file mode 100644 index 00000000..2fb7fc2d --- /dev/null +++ b/gso/migrations/versions/2024-12-05_79192e72131c_add_gs_and_ga_sequences.py @@ -0,0 +1,42 @@ +"""Add GS and GA sequences. + +Revision ID: 79192e72131c +Revises: e36b3bd8a45c +Create Date: 2024-12-05 11:11:41.048264 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '79192e72131c' +down_revision = 'e36b3bd8a45c' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Create GS ID sequence + op.execute(""" + CREATE SEQUENCE gs_id_seq + START WITH 50000 + INCREMENT BY 1 + MINVALUE 50000 + MAXVALUE 99999 + NO CYCLE; + """) + + # Create GA ID sequence + op.execute(""" + CREATE SEQUENCE ga_id_seq + START WITH 50000 + INCREMENT BY 1 + MINVALUE 50000 + MAXVALUE 99999 + NO CYCLE; + """) + + +def downgrade() -> None: + op.execute("DROP SEQUENCE gs_id_seq") + op.execute("DROP SEQUENCE ga_id_seq") -- GitLab