Skip to content

Commit

Permalink
Add the alembic automated migration (needs rework)
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Dec 28, 2024
1 parent 04b18a8 commit 8791cc8
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions ihatemoney/migrations/versions/3334e1f293b4_remove_currencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""remove currencies
Revision ID: 3334e1f293b4
Revises: 7a9b38559992
Create Date: 2024-12-27 00:25:06.517970
"""

# revision identifiers, used by Alembic.
revision = '3334e1f293b4'
down_revision = '7a9b38559992'

from alembic import op
import sqlalchemy as sa


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('bill', schema=None) as batch_op:
batch_op.drop_column('converted_amount')
batch_op.drop_column('original_currency')

with op.batch_alter_table('bill_version', schema=None) as batch_op:
batch_op.alter_column('bill_type',
existing_type=sa.TEXT(),
type_=sa.Enum('EXPENSE', 'REIMBURSEMENT', name='billtype'),
existing_nullable=True,
autoincrement=False)
batch_op.drop_column('converted_amount')
batch_op.drop_column('original_currency')

with op.batch_alter_table('billowers', schema=None) as batch_op:
batch_op.alter_column('bill_id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('person_id',
existing_type=sa.INTEGER(),
nullable=False)

with op.batch_alter_table('project', schema=None) as batch_op:
batch_op.drop_column('default_currency')

with op.batch_alter_table('project_version', schema=None) as batch_op:
batch_op.drop_column('default_currency')

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('project_version', schema=None) as batch_op:
batch_op.add_column(sa.Column('default_currency', sa.VARCHAR(length=3), nullable=True))

with op.batch_alter_table('project', schema=None) as batch_op:
batch_op.add_column(sa.Column('default_currency', sa.VARCHAR(length=3), server_default=sa.text("('')"), nullable=True))

with op.batch_alter_table('billowers', schema=None) as batch_op:
batch_op.alter_column('person_id',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.alter_column('bill_id',
existing_type=sa.INTEGER(),
nullable=True)

with op.batch_alter_table('bill_version', schema=None) as batch_op:
batch_op.add_column(sa.Column('original_currency', sa.VARCHAR(length=3), nullable=True))
batch_op.add_column(sa.Column('converted_amount', sa.FLOAT(), nullable=True))
batch_op.alter_column('bill_type',
existing_type=sa.Enum('EXPENSE', 'REIMBURSEMENT', name='billtype'),
type_=sa.TEXT(),
existing_nullable=True,
autoincrement=False)

with op.batch_alter_table('bill', schema=None) as batch_op:
batch_op.add_column(sa.Column('original_currency', sa.VARCHAR(length=3), server_default=sa.text("('')"), nullable=True))
batch_op.add_column(sa.Column('converted_amount', sa.FLOAT(), nullable=True))

# ### end Alembic commands ###

0 comments on commit 8791cc8

Please sign in to comment.