backend / migration /versions /4e76691ab103_add_income_statement_table.py
praneethys's picture
apis for generate p&l (#9)
a4ef0c7 verified
raw
history blame
1.63 kB
"""add_income_statement_table
Revision ID: 4e76691ab103
Revises: 7ea44cbc5b1f
Create Date: 2024-06-03 23:59:03.717778
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = '4e76691ab103'
down_revision: Union[str, None] = '7ea44cbc5b1f'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('income_statement',
sa.Column('income', postgresql.JSON(astext_type=sa.Text()), nullable=True),
sa.Column('expenses', postgresql.JSON(astext_type=sa.Text()), nullable=True),
sa.Column('date_from', sa.DateTime(), nullable=False),
sa.Column('date_to', sa.DateTime(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_income_statement_id'), 'income_statement', ['id'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_income_statement_id'), table_name='income_statement')
op.drop_table('income_statement')
# ### end Alembic commands ###