948ce5107c93_initial_migration.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """initial_migration
  2. Revision ID: 948ce5107c93
  3. Revises:
  4. Create Date: 2019-08-18 01:45:56.906214
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '948ce5107c93'
  10. down_revision = None
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.create_table('request',
  15. sa.Column('id', sa.Integer(), nullable=False),
  16. sa.Column('name', sa.String(), nullable=True),
  17. sa.PrimaryKeyConstraint('id', name=op.f('pk_request'))
  18. )
  19. op.create_table('user',
  20. sa.Column('id', sa.Integer(), nullable=False),
  21. sa.Column('email', sa.String(), nullable=True),
  22. sa.Column('password', sa.String(), nullable=True),
  23. sa.Column('name', sa.String(), nullable=True),
  24. sa.Column('registration_at', sa.DateTime(), nullable=True),
  25. sa.PrimaryKeyConstraint('id', name=op.f('pk_user'))
  26. )
  27. op.create_table('key',
  28. sa.Column('id', sa.Integer(), nullable=False),
  29. sa.Column('key', sa.String(), nullable=True),
  30. sa.Column('created_at', sa.DateTime(), nullable=True),
  31. sa.Column('expire_at', sa.DateTime(), nullable=True),
  32. sa.Column('active', sa.Boolean(), nullable=True),
  33. sa.Column('used_at', sa.DateTime(), nullable=True),
  34. sa.Column('uses', sa.Integer(), nullable=True),
  35. sa.Column('user_id', sa.Integer(), nullable=True),
  36. sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_key_user_id_user')),
  37. sa.PrimaryKeyConstraint('id', name=op.f('pk_key'))
  38. )
  39. op.create_table('log',
  40. sa.Column('id', sa.Integer(), nullable=False),
  41. sa.Column('succes', sa.Boolean(), nullable=True),
  42. sa.Column('date_time', sa.DateTime(), nullable=True),
  43. sa.Column('key_id', sa.Integer(), nullable=True),
  44. sa.Column('request_id', sa.Integer(), nullable=True),
  45. sa.ForeignKeyConstraint(['key_id'], ['key.id'], name=op.f('fk_log_key_id_key')),
  46. sa.ForeignKeyConstraint(['request_id'], ['request.id'], name=op.f('fk_log_request_id_request')),
  47. sa.PrimaryKeyConstraint('id', name=op.f('pk_log'))
  48. )
  49. def downgrade():
  50. op.drop_table('log')
  51. op.drop_table('key')
  52. op.drop_table('user')
  53. op.drop_table('request')