"""empty message
Revision ID: 0380e8ec69c0
Revises:
Create Date: 2023-02-09 17:00:29.257012
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0380e8ec69c0'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('blog_tag',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='id'),
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
sa.Column('tag_name', sa.String(length=50), nullable=False, comment='标签名'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('blog_type',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='id'),
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
sa.Column('type_name', sa.String(length=50), nullable=False, comment='分类名'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('comment_user',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='id'),
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
sa.Column('nickname', sa.String(length=50), nullable=False, comment='昵称'),
sa.Column('email', sa.String(length=20), nullable=False, comment='邮箱'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='id'),
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
sa.Column('nickname', sa.String(length=48), nullable=False, comment='昵称'),
sa.Column('email', sa.String(length=48), nullable=False, comment='邮箱'),
sa.Column('password', sa.String(length=128), nullable=True, comment='密码'),
sa.Column('head_url', sa.String(length=32), nullable=True, comment='头像'),
sa.Column('slogan', sa.String(length=64), nullable=True, comment='Slogan'),
sa.Column('detail', sa.Text(), nullable=True, comment='详细介绍'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('blog',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='id'),
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
sa.Column('title', sa.String(length=100), nullable=False, comment='标题'),
sa.Column('content', sa.Text(), nullable=False, comment='正文'),
sa.Column('see_num', sa.Integer(), nullable=True, comment='观看数'),
sa.Column('update_time', sa.DateTime(), nullable=True, comment='更新时间'),
sa.Column('type_id', sa.Integer(), nullable=True, comment='分类id'),
sa.Column('user_id', sa.Integer(), nullable=False, comment='创建人id'),
sa.ForeignKeyConstraint(['type_id'], ['blog_type.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('blog_map',
sa.Column('tag_id', sa.Integer(), nullable=False, comment='标签id'),
sa.Column('blog_id', sa.Integer(), nullable=False, comment='文章id'),
sa.ForeignKeyConstraint(['blog_id'], ['blog.id'], ),
sa.ForeignKeyConstraint(['tag_id'], ['blog_tag.id'], ),
sa.PrimaryKeyConstraint('tag_id', 'blog_id')
)
op.create_table('comments',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='id'),
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
sa.Column('comment_content', sa.Text(), nullable=False, comment='评论内容'),
sa.Column('blog_id', sa.Integer(), nullable=True, comment='评论文章id'),
sa.Column('parent_id', sa.Integer(), nullable=True, comment='父评论id'),
sa.Column('user_id', sa.Integer(), nullable=True, comment='评论人id'),
sa.ForeignKeyConstraint(['blog_id'], ['blog.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['comment_user.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('comments')
op.drop_table('blog_map')
op.drop_table('blog')
op.drop_table('user')
op.drop_table('comment_user')
op.drop_table('blog_type')
op.drop_table('blog_tag')
# ### end Alembic commands ###