pyfedi/migrations/versions/27b71f6cb21e_adding_read_posts_table.py

42 lines
1.3 KiB
Python
Raw Normal View History

2024-09-27 07:18:49 -07:00
"""adding read_posts table
Revision ID: 27b71f6cb21e
Revises: fdaeb0b2c078
Create Date: 2024-09-27 10:17:54.020762
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '27b71f6cb21e'
down_revision = 'fdaeb0b2c078'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('read_posts',
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('read_post_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['read_post_id'], ['post.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
)
with op.batch_alter_table('read_posts', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_read_posts_read_post_id'), ['read_post_id'], unique=False)
batch_op.create_index(batch_op.f('ix_read_posts_user_id'), ['user_id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('read_posts', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_read_posts_user_id'))
batch_op.drop_index(batch_op.f('ix_read_posts_read_post_id'))
op.drop_table('read_posts')
# ### end Alembic commands ###