31 lines
920 B
Python
31 lines
920 B
Python
|
|
"""add source_lang and translation_lang to vocabulary
|
||
|
|
|
||
|
|
Revision ID: 20251204_add_vocab_lang
|
||
|
|
Revises:
|
||
|
|
Create Date: 2025-12-04
|
||
|
|
"""
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
import sqlalchemy as sa
|
||
|
|
|
||
|
|
|
||
|
|
# revision identifiers, used by Alembic.
|
||
|
|
revision = '20251204_add_vocab_lang'
|
||
|
|
down_revision = None
|
||
|
|
branch_labels = None
|
||
|
|
depends_on = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade():
|
||
|
|
op.add_column('vocabulary', sa.Column('source_lang', sa.String(length=5), nullable=True))
|
||
|
|
op.add_column('vocabulary', sa.Column('translation_lang', sa.String(length=5), nullable=True))
|
||
|
|
# Create unique constraint for (user_id, source_lang, word_original)
|
||
|
|
op.create_unique_constraint('uq_vocab_user_lang_word', 'vocabulary', ['user_id', 'source_lang', 'word_original'])
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade():
|
||
|
|
op.drop_constraint('uq_vocab_user_lang_word', 'vocabulary', type_='unique')
|
||
|
|
op.drop_column('vocabulary', 'translation_lang')
|
||
|
|
op.drop_column('vocabulary', 'source_lang')
|
||
|
|
|