"""add journal_club_attendance

Revision ID: 14dd4a3b65b1
Revises: 47b3a91c20e3
Create Date: 2026-07-14 09:32:08.518645
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa


revision: str = '14dd4a3b65b1'
down_revision: Union[str, None] = '47b3a91c20e3'
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('journal_club_attendance',
    sa.Column('id', sa.Uuid(), nullable=False),
    sa.Column('tenant_id', sa.Uuid(), nullable=False),
    sa.Column('queue_id', sa.Uuid(), nullable=False),
    sa.Column('user_id', sa.Uuid(), nullable=False),
    sa.Column('attended', sa.Boolean(), nullable=False),
    sa.Column('rating', sa.Integer(), nullable=True),
    sa.Column('comment', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.ForeignKeyConstraint(['queue_id'], ['journal_club_queue.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['tenant_id'], ['tenants.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('ix_jca_queue', 'journal_club_attendance', ['queue_id'], unique=False)
    op.create_index('ix_jca_queue_user', 'journal_club_attendance', ['queue_id', 'user_id'], unique=True)
    op.create_index('ix_jca_tenant', 'journal_club_attendance', ['tenant_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_jca_tenant', table_name='journal_club_attendance')
    op.drop_index('ix_jca_queue_user', table_name='journal_club_attendance')
    op.drop_index('ix_jca_queue', table_name='journal_club_attendance')
    op.drop_table('journal_club_attendance')
    # ### end Alembic commands ###
