"""add_position_courses_table

Revision ID: 0487635b5e95
Revises: 5448c81e7afd
Create Date: 2025-09-22 08:27:52.507507

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '0487635b5e95'
down_revision: Union[str, None] = '5448c81e7afd'
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('position_courses',
    sa.Column('position_id', sa.Integer(), nullable=False, comment='岗位ID'),
    sa.Column('course_id', sa.Integer(), nullable=False, comment='课程ID'),
    sa.Column('course_type', sa.String(length=20), nullable=False, comment='课程类型'),
    sa.Column('priority', sa.Integer(), nullable=True, comment='优先级/排序'),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.Column('is_deleted', sa.Boolean(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['course_id'], ['courses.id'], ),
    sa.ForeignKeyConstraint(['position_id'], ['positions.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('position_id', 'course_id', 'is_deleted', name='uix_position_course')
    )
    op.create_index(op.f('ix_position_courses_id'), 'position_courses', ['id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_position_courses_id'), table_name='position_courses')
    op.drop_table('position_courses')
    # ### end Alembic commands ###