An ebook/comic library service and web client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.3 KiB

  1. """Initial User DB Migration
  2. Revision ID: 96442b147e22
  3. Revises:
  4. Create Date: 2018-07-03 14:22:42.833390
  5. """
  6. import sqlalchemy as sa
  7. from alembic import op
  8. # revision identifiers, used by Alembic.
  9. revision = '96442b147e22'
  10. down_revision = None
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.create_table('user',
  15. sa.Column('id', sa.Integer(), nullable=False),
  16. sa.Column('name', sa.Unicode(length=60), nullable=False),
  17. sa.Column('role', sa.Unicode(length=32), nullable=False),
  18. sa.Column(
  19. 'password_hash',
  20. sa.Unicode(length=128),
  21. nullable=False),
  22. sa.Column(
  23. 'password_revision', sa.SmallInteger(), nullable=False),
  24. sa.Column('creation_time', sa.DateTime(), nullable=False),
  25. sa.Column('last_login_time', sa.DateTime(), nullable=True),
  26. sa.Column('version', sa.Integer(), nullable=False),
  27. sa.PrimaryKeyConstraint('id'),
  28. sa.UniqueConstraint('name'))
  29. op.create_table('user_token',
  30. sa.Column('id', sa.Integer(), nullable=False),
  31. sa.Column('user_id', sa.Integer(), nullable=False),
  32. sa.Column('token', sa.Unicode(length=36), nullable=False),
  33. sa.Column('note', sa.Unicode(length=128), nullable=True),
  34. sa.Column('enabled', sa.Boolean(), nullable=False),
  35. sa.Column('expiration_time', sa.DateTime(), nullable=True),
  36. sa.Column('creation_time', sa.DateTime(), nullable=False),
  37. sa.Column('last_edit_time', sa.DateTime(), nullable=True),
  38. sa.Column('last_usage_time', sa.DateTime(), nullable=True),
  39. sa.Column('version', sa.Integer(), nullable=False),
  40. sa.ForeignKeyConstraint(
  41. ['user_id'], ['user.id'], ondelete='CASCADE'),
  42. sa.PrimaryKeyConstraint('id'))
  43. op.create_index(op.f('ix_user_token_user_id'), 'user_token', ['user_id'],
  44. unique=False)
  45. def downgrade():
  46. op.drop_index(op.f('ix_user_token_user_id'), table_name='user_token')
  47. op.drop_table('user_token')
  48. op.drop_table('user')