44 lines
1.3 KiB
Python
Raw Normal View History

2024-07-29 11:43:52 +08:00
"""empty message
Revision ID: 6419f62abd69
Revises: 688e06991331
Create Date: 2023-04-09 19:03:09.833527
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6419f62abd69'
down_revision = '688e06991331'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('comments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('body', sa.Text(), nullable=True),
sa.Column('timestamp', sa.DateTime(), nullable=True),
sa.Column('author_id', sa.Integer(), nullable=True),
sa.Column('post_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('comments', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_comments_timestamp'), ['timestamp'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('comments', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_comments_timestamp'))
op.drop_table('comments')
# ### end Alembic commands ###