ba34a39acf0e_factory_and_ma_table.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. """factory and ma table
  2. Revision ID: ba34a39acf0e
  3. Revises: e6577173fe0f
  4. Create Date: 2019-09-03 11:37:53.165412
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = 'ba34a39acf0e'
  10. down_revision = 'e6577173fe0f'
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.create_table('factory',
  15. sa.Column('id', sa.Integer(), nullable=False),
  16. sa.Column('name', sa.String(), nullable=True),
  17. sa.Column('player_id', sa.Integer(), nullable=True),
  18. sa.ForeignKeyConstraint(['player_id'], ['player.id'], name=op.f('fk_factory_player_id_player')),
  19. sa.PrimaryKeyConstraint('id', name=op.f('pk_factory'))
  20. )
  21. op.create_table('factory_track',
  22. sa.Column('id', sa.Integer(), nullable=False),
  23. sa.Column('date_time', sa.DateTime(), nullable=True),
  24. sa.Column('state_id', sa.Integer(), nullable=True),
  25. sa.ForeignKeyConstraint(['state_id'], ['state.id'], name=op.f('fk_factory_track_state_id_state')),
  26. sa.PrimaryKeyConstraint('id', name=op.f('pk_factory_track'))
  27. )
  28. op.create_table('military_academy',
  29. sa.Column('id', sa.Integer(), nullable=False),
  30. sa.Column('date_time', sa.DateTime(), nullable=True),
  31. sa.Column('player_id', sa.Integer(), nullable=True),
  32. sa.Column('region_id', sa.Integer(), nullable=True),
  33. sa.ForeignKeyConstraint(['player_id'], ['player.id'], name=op.f('fk_military_academy_player_id_player')),
  34. sa.ForeignKeyConstraint(['region_id'], ['region.id'], name=op.f('fk_military_academy_region_id_region')),
  35. sa.PrimaryKeyConstraint('id', name=op.f('pk_military_academy'))
  36. )
  37. op.create_table('factory_stat',
  38. sa.Column('id', sa.Integer(), nullable=False),
  39. sa.Column('level', sa.SmallInteger(), nullable=True),
  40. sa.Column('workers', sa.SmallInteger(), nullable=True),
  41. sa.Column('experience', sa.Integer(), nullable=True),
  42. sa.Column('wage', sa.Integer(), nullable=True),
  43. sa.Column('factory_id', sa.Integer(), nullable=True),
  44. sa.Column('factory_track_id', sa.Integer(), nullable=True),
  45. sa.Column('region_id', sa.Integer(), nullable=True),
  46. sa.ForeignKeyConstraint(['factory_id'], ['factory.id'], name=op.f('fk_factory_stat_factory_id_factory')),
  47. sa.ForeignKeyConstraint(['factory_track_id'], ['factory_track.id'], name=op.f('fk_factory_stat_factory_track_id_factory_track')),
  48. sa.ForeignKeyConstraint(['region_id'], ['region.id'], name=op.f('fk_factory_stat_region_id_region')),
  49. sa.PrimaryKeyConstraint('id', name=op.f('pk_factory_stat'))
  50. )
  51. def downgrade():
  52. op.drop_table('factory_stat')
  53. op.drop_table('military_academy')
  54. op.drop_table('factory_track')
  55. op.drop_table('factory')