"""Defined interaction domain 2

Revision ID: 53fee8f13cdb
Revises: 505b61314bba
Create Date: 2024-05-20 08:37:25.182616

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '53fee8f13cdb'
down_revision = '505b61314bba'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('chat_session',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('session_start', sa.DateTime(), nullable=False),
    sa.Column('session_end', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['public.user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('interaction',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('chat_session_id', sa.Integer(), nullable=False),
    sa.Column('question', sa.Text(), nullable=False),
    sa.Column('answer', sa.Text(), nullable=True),
    sa.Column('language', sa.String(length=2), nullable=False),
    sa.Column('appreciation', sa.Integer(), nullable=True),
    sa.Column('question_at', sa.DateTime(), nullable=False),
    sa.Column('answer_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['chat_session_id'], ['chat_session.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('interaction_embedding',
    sa.Column('interaction_id', sa.Integer(), nullable=False),
    sa.Column('embedding_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['embedding_id'], ['embeddings.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['interaction_id'], ['interaction.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('interaction_id', 'embedding_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('interaction_embedding')
    op.drop_table('interaction')
    op.drop_table('chat_session')
    # ### end Alembic commands ###
