"""savings_record table

Revision ID: bf2a67c0e2ab
Revises: 3d9cb19df76f
Create Date: 2026-05-24 16:24:34.622394

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'bf2a67c0e2ab'
down_revision: Union[str, Sequence[str], None] = '3d9cb19df76f'
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('savings_record',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('order_amount_cents', sa.Integer(), nullable=False),
    sa.Column('saved_amount_cents', sa.Integer(), nullable=False),
    sa.Column('platform', sa.String(length=32), nullable=True),
    sa.Column('title', sa.String(length=128), nullable=True),
    sa.Column('source', sa.String(length=16), nullable=False),
    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('savings_record', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_savings_record_created_at'), ['created_at'], unique=False)
        batch_op.create_index(batch_op.f('ix_savings_record_user_id'), ['user_id'], unique=False)

    # ### end Alembic commands ###


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

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