"""add_billed_amount_to_berita_acara

Revision ID: d8e78c1f04f5
Revises: 96214ecca77c
Create Date: 2026-04-27 19:24:50.930527

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'd8e78c1f04f5'
down_revision: Union[str, Sequence[str], None] = '96214ecca77c'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_berita_acara_prompts_id'), table_name='berita_acara_prompts')
    op.drop_table('berita_acara_prompts')
    op.drop_index(op.f('ix_transactions_id'), table_name='transactions')
    op.drop_table('transactions')
    op.drop_index(op.f('ix_service_rates_id'), table_name='service_rates')
    op.drop_table('service_rates')
    op.drop_index(op.f('ix_berita_acara_id'), table_name='berita_acara')
    op.drop_index(op.f('ix_berita_acara_task_id'), table_name='berita_acara')
    op.drop_index(op.f('ix_berita_acara_user_id'), table_name='berita_acara')
    op.drop_table('berita_acara')
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('berita_acara',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('task_id', sa.INTEGER(), nullable=False),
    sa.Column('user_id', sa.INTEGER(), nullable=True),
    sa.Column('title', sa.VARCHAR(), nullable=True),
    sa.Column('qa_json_encrypted', sa.TEXT(), nullable=True),
    sa.Column('prompt_used', sa.TEXT(), nullable=True),
    sa.Column('status', sa.VARCHAR(), nullable=True),
    sa.Column('error_message', sa.TEXT(), nullable=True),
    sa.Column('model_used', sa.VARCHAR(), nullable=True),
    sa.Column('processing_time', sa.VARCHAR(), nullable=True),
    sa.Column('created_at', sa.DATETIME(), nullable=True),
    sa.Column('updated_at', sa.DATETIME(), nullable=True),
    sa.ForeignKeyConstraint(['task_id'], ['transkripsi_tasks.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='SET NULL'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_berita_acara_user_id'), 'berita_acara', ['user_id'], unique=False)
    op.create_index(op.f('ix_berita_acara_task_id'), 'berita_acara', ['task_id'], unique=False)
    op.create_index(op.f('ix_berita_acara_id'), 'berita_acara', ['id'], unique=False)
    op.create_table('service_rates',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('key', sa.VARCHAR(), nullable=False),
    sa.Column('value', sa.INTEGER(), nullable=False),
    sa.Column('updated_at', sa.DATETIME(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('key')
    )
    op.create_index(op.f('ix_service_rates_id'), 'service_rates', ['id'], unique=False)
    op.create_table('transactions',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('user_id', sa.INTEGER(), nullable=False),
    sa.Column('amount', sa.INTEGER(), nullable=False),
    sa.Column('service_type', sa.VARCHAR(length=13), nullable=False),
    sa.Column('task_id', sa.INTEGER(), nullable=True),
    sa.Column('ba_id', sa.INTEGER(), nullable=True),
    sa.Column('description', sa.VARCHAR(), nullable=True),
    sa.Column('created_at', sa.DATETIME(), nullable=True),
    sa.ForeignKeyConstraint(['ba_id'], ['berita_acara.id'], ondelete='SET NULL'),
    sa.ForeignKeyConstraint(['task_id'], ['transkripsi_tasks.id'], ondelete='SET NULL'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_transactions_id'), 'transactions', ['id'], unique=False)
    op.create_table('berita_acara_prompts',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(), nullable=True),
    sa.Column('prompt_text', sa.TEXT(), nullable=False),
    sa.Column('is_active', sa.BOOLEAN(), nullable=True),
    sa.Column('updated_by', sa.INTEGER(), nullable=True),
    sa.Column('created_at', sa.DATETIME(), nullable=True),
    sa.Column('updated_at', sa.DATETIME(), nullable=True),
    sa.ForeignKeyConstraint(['updated_by'], ['users.id'], ondelete='SET NULL'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_index(op.f('ix_berita_acara_prompts_id'), 'berita_acara_prompts', ['id'], unique=False)
    # ### end Alembic commands ###
