Skip to content

Commit 3cce209

Browse files
committed
TRACK-307, migration script to add new ministries
1 parent 4c09fcc commit 3cce209

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""add new ministries
2+
3+
Revision ID: eccbb8b96011
4+
Revises: 09fb62ec79e9
5+
Create Date: 2025-01-02 15:19:17.743999
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import postgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = 'eccbb8b96011'
14+
down_revision = '09fb62ec79e9'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
op.execute("UPDATE ministries SET sort_order = sort_order + 7 WHERE name != 'Not Applicable'")
21+
op.execute("INSERT INTO ministries (name,abbreviation,sort_order) values ('Mining and Critical Minerals','MCM',1)")
22+
op.execute("INSERT INTO ministries (name,abbreviation,sort_order) values ('Forests','FOR',2)")
23+
op.execute("INSERT INTO ministries (name,abbreviation,sort_order) values ('Jobs, Economic Development and Innovation','JEDI',3)")
24+
op.execute("INSERT INTO ministries (name,abbreviation,sort_order) values ('Tourism, Arts, Culture and Sport','TACS',4)")
25+
op.execute("INSERT INTO ministries (name,abbreviation,sort_order) values ('Housing and Municipal Affairs','HOUS',5)")
26+
op.execute("INSERT INTO ministries (name,abbreviation,sort_order) values ('Water, Land and Resource Stewardship','WLRS',6)")
27+
op.execute("INSERT INTO ministries (name,abbreviation,sort_order) values ('Transportation and Transit','MOTI',7)")
28+
29+
30+
def downgrade():
31+
op.execute("DELETE FROM ministries WHERE name IN ('Mining and Critical Minerals', 'Forests', 'Jobs, Economic Development and Innovation', 'Tourism, Arts, Culture and Sport', 'Housing and Municipal Affairs', 'Water, Land and Resource Stewardship', 'Transportation and Transit')")
32+
op.execute("UPDATE ministries SET sort_order = sort_order - 7 WHERE name != 'Not Applicable'")

0 commit comments

Comments
 (0)