2024-07-29 11:43:52 +08:00

53 lines
1.7 KiB
Python

"""empty message
Revision ID: 6630335c7b63
Revises: 39e44c8af34c
Create Date: 2023-04-06 20:56:08.891686
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6630335c7b63'
down_revision = '39e44c8af34c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('posts',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.Text(), nullable=True),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('img_path', sa.String(length=64), nullable=True),
sa.Column('collect_num', sa.Integer(), nullable=True),
sa.Column('comment_num', sa.Integer(), nullable=True),
sa.Column('like_num', sa.Integer(), nullable=True),
sa.Column('timestamp', sa.DateTime(), nullable=True),
sa.Column('author_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('posts', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_posts_timestamp'), ['timestamp'], unique=False)
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.add_column(sa.Column('avatar_path', sa.String(length=128), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.drop_column('avatar_path')
with op.batch_alter_table('posts', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_posts_timestamp'))
op.drop_table('posts')
# ### end Alembic commands ###