|
|
"""Initial migration
|
|
|
|
|
|
Revision ID: 76211a5a2c25
|
|
|
Revises:
|
|
|
Create Date: 2024-07-03 21:19:17.615766
|
|
|
|
|
|
"""
|
|
|
from alembic import op
|
|
|
import sqlalchemy as sa
|
|
|
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
|
revision = '76211a5a2c25'
|
|
|
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 ###
|