931dee70fc71_initial_migration.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """Initial migration
  2. Revision ID: 931dee70fc71
  3. Revises:
  4. Create Date: 2019-08-21 17:19:36.721148
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '931dee70fc71'
  10. down_revision = None
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.create_table('region',
  15. sa.Column('id', sa.Integer(), nullable=False),
  16. sa.Column('name', sa.String(), nullable=True),
  17. sa.Column('gold_limit', sa.SmallInteger(), nullable=True),
  18. sa.Column('oil_limit', sa.SmallInteger(), nullable=True),
  19. sa.Column('ore_limit', sa.SmallInteger(), nullable=True),
  20. sa.Column('uranium_limit', sa.SmallInteger(), nullable=True),
  21. sa.Column('diamond_limit', sa.SmallInteger(), nullable=True),
  22. sa.PrimaryKeyConstraint('id', name=op.f('pk_region'))
  23. )
  24. op.create_table('state',
  25. sa.Column('id', sa.Integer(), nullable=False),
  26. sa.Column('name', sa.String(), nullable=True),
  27. sa.PrimaryKeyConstraint('id', name=op.f('pk_state'))
  28. )
  29. op.create_table('deep_exploration',
  30. sa.Column('id', sa.Integer(), nullable=False),
  31. sa.Column('date_time_end', sa.DateTime(), nullable=True),
  32. sa.Column('resource_type', sa.SmallInteger(), nullable=True),
  33. sa.Column('region_id', sa.Integer(), nullable=True),
  34. sa.ForeignKeyConstraint(['region_id'], ['region.id'], name=op.f('fk_deep_exploration_region_id_region')),
  35. sa.PrimaryKeyConstraint('id', name=op.f('pk_deep_exploration'))
  36. )
  37. op.create_table('resource_track',
  38. sa.Column('id', sa.Integer(), nullable=False),
  39. sa.Column('resource_type', sa.SmallInteger(), nullable=True),
  40. sa.Column('date_time', sa.DateTime(), nullable=True),
  41. sa.Column('state_id', sa.Integer(), nullable=True),
  42. sa.ForeignKeyConstraint(['state_id'], ['state.id'], name=op.f('fk_resource_track_state_id_state')),
  43. sa.PrimaryKeyConstraint('id', name=op.f('pk_resource_track'))
  44. )
  45. op.create_table('resource_stat',
  46. sa.Column('id', sa.Integer(), nullable=False),
  47. sa.Column('explored', sa.SmallInteger(), nullable=True),
  48. sa.Column('deep_exploration', sa.SmallInteger(), nullable=True),
  49. sa.Column('percentage_explored', sa.SmallInteger(), nullable=True),
  50. sa.Column('percentage_total', sa.SmallInteger(), nullable=True),
  51. sa.Column('resource_track_id', sa.Integer(), nullable=True),
  52. sa.Column('region_id', sa.Integer(), nullable=True),
  53. sa.ForeignKeyConstraint(['region_id'], ['region.id'], name=op.f('fk_resource_stat_region_id_region')),
  54. sa.ForeignKeyConstraint(['resource_track_id'], ['resource_track.id'], name=op.f('fk_resource_stat_resource_track_id_resource_track')),
  55. sa.PrimaryKeyConstraint('id', name=op.f('pk_resource_stat'))
  56. )
  57. def downgrade():
  58. op.drop_table('resource_stat')
  59. op.drop_table('resource_track')
  60. op.drop_table('deep_exploration')
  61. op.drop_table('state')
  62. op.drop_table('region')