You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

53 lines
1.8 KiB

"""Initial migration
Revision ID: d9fde422c66a
Revises:
Create Date: 2024-07-03 21:50:28.902854
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd9fde422c66a'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('account',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=True),
sa.Column('account_type', sa.String(length=64), nullable=True),
sa.Column('balance', sa.Float(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('account', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_account_name'), ['name'], unique=True)
op.create_table('transaction',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('amount', sa.Float(), nullable=True),
sa.Column('type', sa.String(length=64), nullable=True),
sa.Column('date', sa.DateTime(), nullable=True),
sa.Column('source_account_id', sa.Integer(), nullable=True),
sa.Column('destination_account_id', sa.Integer(), nullable=True),
sa.Column('concept', sa.String(length=128), nullable=True),
sa.ForeignKeyConstraint(['destination_account_id'], ['account.id'], ),
sa.ForeignKeyConstraint(['source_account_id'], ['account.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('transaction')
with op.batch_alter_table('account', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_account_name'))
op.drop_table('account')
# ### end Alembic commands ###