"""add dictionary_sense_link table Revision ID: 0010 Revises: 0009 Create Date: 2026-04-10 """ from typing import Sequence, Union import sqlalchemy as sa from alembic import op from sqlalchemy.dialects import postgresql revision: str = "0010" down_revision: Union[str, None] = "0009" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table( "dictionary_sense_link", sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True), sa.Column( "sense_id", postgresql.UUID(as_uuid=True), sa.ForeignKey("dictionary_sense.id", ondelete="CASCADE"), nullable=False, ), sa.Column("link_text", sa.Text(), nullable=False), sa.Column("link_target", sa.Text(), nullable=False), sa.Column("target_lemma_id", postgresql.UUID(as_uuid=True), nullable=True), ) op.create_index("ix_dictionary_sense_link_sense_id", "dictionary_sense_link", ["sense_id"]) op.create_index("ix_dictionary_sense_link_target_lemma_id", "dictionary_sense_link", ["target_lemma_id"]) def downgrade() -> None: op.drop_index("ix_dictionary_sense_link_target_lemma_id", table_name="dictionary_sense_link") op.drop_index("ix_dictionary_sense_link_sense_id", table_name="dictionary_sense_link") op.drop_table("dictionary_sense_link")