"""Feedback chunk entity added

Revision ID: 80f5954656f0
Revises: ed91cdf82ef3
Create Date: 2025-11-20 00:08:44.850150

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '80f5954656f0'
down_revision: Union[str, Sequence[str], None] = 'ed91cdf82ef3'
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.create_table('feedback_chunk_update',
    sa.Column('feedback_id', sa.Integer(), nullable=False),
    sa.Column('chunk_id', sa.Integer(), nullable=True),
    sa.Column('document_id', sa.Integer(), nullable=True),
    sa.Column('update_type', sa.String(length=50), nullable=False),
    sa.Column('new_content', sa.Text(), nullable=False),
    sa.Column('original_text_snapshot', sa.Text(), nullable=True),
    sa.Column('status', sa.String(length=50), nullable=False),
    sa.Column('was_cited', sa.Boolean(), nullable=False),
    sa.Column('marked_irrelevant', sa.Boolean(), nullable=False),
    sa.Column('updated_in_analysis_id', sa.Integer(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.ForeignKeyConstraint(['chunk_id'], ['chunk.id'], name=op.f('feedback_chunk_update_chunk_id_fkey')),
    sa.ForeignKeyConstraint(['document_id'], ['document.id'], name=op.f('feedback_chunk_update_document_id_fkey')),
    sa.ForeignKeyConstraint(['feedback_id'], ['feedback.id'], name=op.f('feedback_chunk_update_feedback_id_fkey')),
    sa.ForeignKeyConstraint(['updated_in_analysis_id'], ['feedback_analysis.id'], name=op.f('feedback_chunk_update_updated_in_analysis_id_fkey')),
    sa.PrimaryKeyConstraint('id', name=op.f('feedback_chunk_update_pkey')),
    sa.UniqueConstraint('feedback_id', 'chunk_id', name='uq_feedback_chunk_update')
    )
    op.create_index(op.f('feedback_chunk_update_chunk_id_idx'), 'feedback_chunk_update', ['chunk_id'], unique=False)
    op.create_index(op.f('feedback_chunk_update_document_id_idx'), 'feedback_chunk_update', ['document_id'], unique=False)
    op.create_index(op.f('feedback_chunk_update_feedback_id_idx'), 'feedback_chunk_update', ['feedback_id'], unique=False)
    op.create_index(op.f('feedback_chunk_update_id_idx'), 'feedback_chunk_update', ['id'], unique=False)
    op.create_index(op.f('feedback_chunk_update_status_idx'), 'feedback_chunk_update', ['status'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('feedback_chunk_update_status_idx'), table_name='feedback_chunk_update')
    op.drop_index(op.f('feedback_chunk_update_id_idx'), table_name='feedback_chunk_update')
    op.drop_index(op.f('feedback_chunk_update_feedback_id_idx'), table_name='feedback_chunk_update')
    op.drop_index(op.f('feedback_chunk_update_document_id_idx'), table_name='feedback_chunk_update')
    op.drop_index(op.f('feedback_chunk_update_chunk_id_idx'), table_name='feedback_chunk_update')
    op.drop_table('feedback_chunk_update')
    # ### end Alembic commands ###
