Skip to content

Commit 8791cc8

Browse files
committed
Add the alembic automated migration (needs rework)
1 parent 04b18a8 commit 8791cc8

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
"""remove currencies
2+
3+
Revision ID: 3334e1f293b4
4+
Revises: 7a9b38559992
5+
Create Date: 2024-12-27 00:25:06.517970
6+
7+
"""
8+
9+
# revision identifiers, used by Alembic.
10+
revision = '3334e1f293b4'
11+
down_revision = '7a9b38559992'
12+
13+
from alembic import op
14+
import sqlalchemy as sa
15+
16+
17+
def upgrade():
18+
# ### commands auto generated by Alembic - please adjust! ###
19+
with op.batch_alter_table('bill', schema=None) as batch_op:
20+
batch_op.drop_column('converted_amount')
21+
batch_op.drop_column('original_currency')
22+
23+
with op.batch_alter_table('bill_version', schema=None) as batch_op:
24+
batch_op.alter_column('bill_type',
25+
existing_type=sa.TEXT(),
26+
type_=sa.Enum('EXPENSE', 'REIMBURSEMENT', name='billtype'),
27+
existing_nullable=True,
28+
autoincrement=False)
29+
batch_op.drop_column('converted_amount')
30+
batch_op.drop_column('original_currency')
31+
32+
with op.batch_alter_table('billowers', schema=None) as batch_op:
33+
batch_op.alter_column('bill_id',
34+
existing_type=sa.INTEGER(),
35+
nullable=False)
36+
batch_op.alter_column('person_id',
37+
existing_type=sa.INTEGER(),
38+
nullable=False)
39+
40+
with op.batch_alter_table('project', schema=None) as batch_op:
41+
batch_op.drop_column('default_currency')
42+
43+
with op.batch_alter_table('project_version', schema=None) as batch_op:
44+
batch_op.drop_column('default_currency')
45+
46+
# ### end Alembic commands ###
47+
48+
49+
def downgrade():
50+
# ### commands auto generated by Alembic - please adjust! ###
51+
with op.batch_alter_table('project_version', schema=None) as batch_op:
52+
batch_op.add_column(sa.Column('default_currency', sa.VARCHAR(length=3), nullable=True))
53+
54+
with op.batch_alter_table('project', schema=None) as batch_op:
55+
batch_op.add_column(sa.Column('default_currency', sa.VARCHAR(length=3), server_default=sa.text("('')"), nullable=True))
56+
57+
with op.batch_alter_table('billowers', schema=None) as batch_op:
58+
batch_op.alter_column('person_id',
59+
existing_type=sa.INTEGER(),
60+
nullable=True)
61+
batch_op.alter_column('bill_id',
62+
existing_type=sa.INTEGER(),
63+
nullable=True)
64+
65+
with op.batch_alter_table('bill_version', schema=None) as batch_op:
66+
batch_op.add_column(sa.Column('original_currency', sa.VARCHAR(length=3), nullable=True))
67+
batch_op.add_column(sa.Column('converted_amount', sa.FLOAT(), nullable=True))
68+
batch_op.alter_column('bill_type',
69+
existing_type=sa.Enum('EXPENSE', 'REIMBURSEMENT', name='billtype'),
70+
type_=sa.TEXT(),
71+
existing_nullable=True,
72+
autoincrement=False)
73+
74+
with op.batch_alter_table('bill', schema=None) as batch_op:
75+
batch_op.add_column(sa.Column('original_currency', sa.VARCHAR(length=3), server_default=sa.text("('')"), nullable=True))
76+
batch_op.add_column(sa.Column('converted_amount', sa.FLOAT(), nullable=True))
77+
78+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)