Skip to content

Commit cf5c87e

Browse files
committed
db migration from expense name to transaction name
1 parent b44bce9 commit cf5c87e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Changed expense to transaction table name
2+
3+
Revision ID: 08290ef9350a
4+
Revises: 65dd6b98e39b
5+
Create Date: 2025-03-30 13:45:33.183542
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
from sqlalchemy.dialects import postgresql
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = '08290ef9350a'
16+
down_revision: Union[str, None] = '65dd6b98e39b'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
"""Upgrade schema."""
23+
# ### commands auto generated by Alembic - please adjust! ###
24+
op.drop_index('ix_transactions_id', table_name='transactions')
25+
op.drop_table('transactions')
26+
op.drop_index('ix_expenses_description', table_name='expenses')
27+
op.drop_index('ix_expenses_id', table_name='expenses')
28+
op.drop_table('expenses')
29+
# ### end Alembic commands ###
30+
31+
32+
def downgrade() -> None:
33+
"""Downgrade schema."""
34+
# ### commands auto generated by Alembic - please adjust! ###
35+
op.create_table('expenses',
36+
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
37+
sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=True),
38+
sa.Column('amount', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False),
39+
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
40+
sa.PrimaryKeyConstraint('id', name='expenses_pkey')
41+
)
42+
op.create_index('ix_expenses_id', 'expenses', ['id'], unique=False)
43+
op.create_index('ix_expenses_description', 'expenses', ['description'], unique=False)
44+
op.create_table('transactions',
45+
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
46+
sa.Column('amount', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False),
47+
sa.Column('method', postgresql.ENUM('BANK_TRANSFER', 'CREDIT_CARD', 'DEBIT_CARD', 'CASH', 'PAYPAL', 'OTHER', name='transactionmethod'), autoincrement=False, nullable=False),
48+
sa.Column('date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
49+
sa.Column('description', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
50+
sa.PrimaryKeyConstraint('id', name='transactions_pkey')
51+
)
52+
op.create_index('ix_transactions_id', 'transactions', ['id'], unique=False)
53+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)