"""cash_transaction table

Revision ID: 3d9cb19df76f
Revises: 357520ea3015
Create Date: 2026-05-24 16:21:22.950992

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '3d9cb19df76f'
down_revision: Union[str, Sequence[str], None] = '357520ea3015'
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('cash_transaction',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('amount_cents', sa.Integer(), nullable=False),
    sa.Column('balance_after_cents', sa.Integer(), nullable=False),
    sa.Column('biz_type', sa.String(length=32), nullable=False),
    sa.Column('ref_id', sa.String(length=64), nullable=True),
    sa.Column('remark', sa.String(length=128), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('cash_transaction', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_cash_transaction_created_at'), ['created_at'], unique=False)
        batch_op.create_index(batch_op.f('ix_cash_transaction_user_id'), ['user_id'], unique=False)

    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('cash_transaction', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_cash_transaction_user_id'))
        batch_op.drop_index(batch_op.f('ix_cash_transaction_created_at'))

    op.drop_table('cash_transaction')
    # ### end Alembic commands ###
