566a5752c06e_.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. """empty message
  2. Revision ID: 566a5752c06e
  3. Revises:
  4. Create Date: 2022-10-16 17:02:52.251961
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '566a5752c06e'
  10. down_revision = None
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. # ### commands auto generated by Alembic - please adjust! ###
  15. op.create_table('archive',
  16. sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
  17. sa.Column('name', sa.String(length=32), nullable=False),
  18. sa.Column('describe', sa.String(length=100), nullable=False),
  19. sa.PrimaryKeyConstraint('id'),
  20. sa.UniqueConstraint('name')
  21. )
  22. op.create_table('role',
  23. sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
  24. sa.Column('name', sa.String(length=32), nullable=False),
  25. sa.Column('permission', sa.Integer(), nullable=False),
  26. sa.PrimaryKeyConstraint('id'),
  27. sa.UniqueConstraint('name')
  28. )
  29. op.create_table('user',
  30. sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
  31. sa.Column('email', sa.String(length=32), nullable=False),
  32. sa.Column('passwd_hash', sa.String(length=128), nullable=False),
  33. sa.Column('role_id', sa.Integer(), nullable=True),
  34. sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
  35. sa.PrimaryKeyConstraint('id'),
  36. sa.UniqueConstraint('email')
  37. )
  38. op.create_table('comment',
  39. sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
  40. sa.Column('title', sa.String(length=32), nullable=True),
  41. sa.Column('content', sa.Text(), nullable=False),
  42. sa.Column('create_time', sa.DateTime(), nullable=False),
  43. sa.Column('update_time', sa.DateTime(), nullable=False),
  44. sa.Column('auth_id', sa.Integer(), nullable=False),
  45. sa.Column('father_id', sa.Integer(), nullable=True),
  46. sa.ForeignKeyConstraint(['auth_id'], ['user.id'], ),
  47. sa.ForeignKeyConstraint(['father_id'], ['comment.id'], ),
  48. sa.PrimaryKeyConstraint('id')
  49. )
  50. op.create_table('follow',
  51. sa.Column('time', sa.DateTime(), nullable=False),
  52. sa.Column('follower_id', sa.Integer(), nullable=True),
  53. sa.Column('followed_id', sa.Integer(), nullable=True),
  54. sa.ForeignKeyConstraint(['followed_id'], ['user.id'], ),
  55. sa.ForeignKeyConstraint(['follower_id'], ['user.id'], ),
  56. sa.PrimaryKeyConstraint('follower_id', 'followed_id')
  57. )
  58. op.create_table('archive_comment',
  59. sa.Column('archive_id', sa.Integer(), nullable=False),
  60. sa.Column('comment_id', sa.Integer(), nullable=False),
  61. sa.ForeignKeyConstraint(['archive_id'], ['archive.id'], ),
  62. sa.ForeignKeyConstraint(['comment_id'], ['comment.id'], ),
  63. sa.PrimaryKeyConstraint('archive_id', 'comment_id')
  64. )
  65. # ### end Alembic commands ###
  66. def downgrade():
  67. # ### commands auto generated by Alembic - please adjust! ###
  68. op.drop_table('archive_comment')
  69. op.drop_table('follow')
  70. op.drop_table('comment')
  71. op.drop_table('user')
  72. op.drop_table('role')
  73. op.drop_table('archive')
  74. # ### end Alembic commands ###