|
@@ -0,0 +1,82 @@
|
|
|
+"""empty message
|
|
|
+
|
|
|
+Revision ID: e6b4151608e7
|
|
|
+Revises:
|
|
|
+Create Date: 2022-10-15 18:47:18.044633
|
|
|
+
|
|
|
+"""
|
|
|
+from alembic import op
|
|
|
+import sqlalchemy as sa
|
|
|
+
|
|
|
+
|
|
|
+# revision identifiers, used by Alembic.
|
|
|
+revision = 'e6b4151608e7'
|
|
|
+down_revision = None
|
|
|
+branch_labels = None
|
|
|
+depends_on = None
|
|
|
+
|
|
|
+
|
|
|
+def upgrade():
|
|
|
+ # ### commands auto generated by Alembic - please adjust! ###
|
|
|
+ op.create_table('archive',
|
|
|
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
|
+ sa.Column('name', sa.String(length=32), nullable=False),
|
|
|
+ sa.Column('describe', sa.String(length=100), nullable=False),
|
|
|
+ sa.PrimaryKeyConstraint('id'),
|
|
|
+ sa.UniqueConstraint('name')
|
|
|
+ )
|
|
|
+ op.create_table('role',
|
|
|
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
|
+ sa.Column('name', sa.String(length=32), nullable=False),
|
|
|
+ sa.Column('permission', sa.Integer(), nullable=False),
|
|
|
+ sa.PrimaryKeyConstraint('id'),
|
|
|
+ sa.UniqueConstraint('name')
|
|
|
+ )
|
|
|
+ op.create_table('user',
|
|
|
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
|
+ sa.Column('email', sa.String(length=32), nullable=False),
|
|
|
+ sa.Column('passwd_hash', sa.String(length=128), nullable=False),
|
|
|
+ sa.Column('role_id', sa.Integer(), nullable=True),
|
|
|
+ sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
|
|
|
+ sa.PrimaryKeyConstraint('id'),
|
|
|
+ sa.UniqueConstraint('email')
|
|
|
+ )
|
|
|
+ op.create_table('comment',
|
|
|
+ sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
|
+ sa.Column('title', sa.String(length=32), nullable=True),
|
|
|
+ sa.Column('content', sa.Text(), nullable=False),
|
|
|
+ sa.Column('create_time', sa.DateTime(), nullable=False),
|
|
|
+ sa.Column('update_time', sa.DateTime(), nullable=False),
|
|
|
+ sa.Column('auth_id', sa.Integer(), nullable=True),
|
|
|
+ sa.Column('father_id', sa.Integer(), nullable=True),
|
|
|
+ sa.ForeignKeyConstraint(['auth_id'], ['user.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['father_id'], ['comment.id'], ),
|
|
|
+ sa.PrimaryKeyConstraint('id', 'auth_id', 'father_id')
|
|
|
+ )
|
|
|
+ op.create_table('follow',
|
|
|
+ sa.Column('time', sa.DateTime(), nullable=False),
|
|
|
+ sa.Column('follower_id', sa.Integer(), nullable=True),
|
|
|
+ sa.Column('followed_id', sa.Integer(), nullable=True),
|
|
|
+ sa.ForeignKeyConstraint(['followed_id'], ['user.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['follower_id'], ['user.id'], ),
|
|
|
+ sa.PrimaryKeyConstraint('follower_id', 'followed_id')
|
|
|
+ )
|
|
|
+ op.create_table('archive_comment',
|
|
|
+ sa.Column('archive_id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('comment_id', sa.Integer(), nullable=False),
|
|
|
+ sa.ForeignKeyConstraint(['archive_id'], ['archive.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['comment_id'], ['comment.id'], ),
|
|
|
+ sa.PrimaryKeyConstraint('archive_id', 'comment_id')
|
|
|
+ )
|
|
|
+ # ### end Alembic commands ###
|
|
|
+
|
|
|
+
|
|
|
+def downgrade():
|
|
|
+ # ### commands auto generated by Alembic - please adjust! ###
|
|
|
+ op.drop_table('archive_comment')
|
|
|
+ op.drop_table('follow')
|
|
|
+ op.drop_table('comment')
|
|
|
+ op.drop_table('user')
|
|
|
+ op.drop_table('role')
|
|
|
+ op.drop_table('archive')
|
|
|
+ # ### end Alembic commands ###
|