pyfedi/migrations/versions/980966fba5f4_post_one_language.py

42 lines
1.4 KiB
Python

"""post one language
Revision ID: 980966fba5f4
Revises: fd2af23f4b1f
Create Date: 2024-04-16 21:23:34.642869
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '980966fba5f4'
down_revision = 'fd2af23f4b1f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('post_language')
with op.batch_alter_table('post', schema=None) as batch_op:
batch_op.add_column(sa.Column('language_id', sa.Integer(), nullable=True))
batch_op.create_index(batch_op.f('ix_post_language_id'), ['language_id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('post', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_language_id'))
batch_op.drop_column('language_id')
op.create_table('post_language',
sa.Column('post_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('language_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['language_id'], ['language.id'], name='post_language_language_id_fkey'),
sa.ForeignKeyConstraint(['post_id'], ['post.id'], name='post_language_post_id_fkey'),
sa.PrimaryKeyConstraint('post_id', 'language_id', name='post_language_pkey')
)
# ### end Alembic commands ###