38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
|
|
"""Add word_translations table for multiple translations with context
|
||
|
|
|
||
|
|
Revision ID: 20251206_word_translations
|
||
|
|
Revises: 20251205_wordsource_ai_task
|
||
|
|
Create Date: 2025-12-06
|
||
|
|
"""
|
||
|
|
from typing import Sequence, Union
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
import sqlalchemy as sa
|
||
|
|
|
||
|
|
|
||
|
|
# revision identifiers, used by Alembic.
|
||
|
|
revision: str = '20251206_word_translations'
|
||
|
|
down_revision: Union[str, None] = '20251205_wordsource_ai_task'
|
||
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
||
|
|
depends_on: Union[str, Sequence[str], None] = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
op.create_table(
|
||
|
|
'word_translations',
|
||
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
|
sa.Column('vocabulary_id', sa.Integer(), nullable=False),
|
||
|
|
sa.Column('translation', sa.String(255), nullable=False),
|
||
|
|
sa.Column('context', sa.String(500), nullable=True),
|
||
|
|
sa.Column('context_translation', sa.String(500), nullable=True),
|
||
|
|
sa.Column('is_primary', sa.Boolean(), nullable=False, server_default='false'),
|
||
|
|
sa.Column('created_at', sa.DateTime(), nullable=False, server_default=sa.func.now()),
|
||
|
|
sa.PrimaryKeyConstraint('id')
|
||
|
|
)
|
||
|
|
op.create_index('ix_word_translations_vocabulary_id', 'word_translations', ['vocabulary_id'])
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
op.drop_index('ix_word_translations_vocabulary_id', table_name='word_translations')
|
||
|
|
op.drop_table('word_translations')
|