diff --git a/migrations/versions/3f3b01817d48_.py b/migrations/versions/3f3b01817d48_.py new file mode 100644 index 00000000..8b5a679d --- /dev/null +++ b/migrations/versions/3f3b01817d48_.py @@ -0,0 +1,93 @@ +"""empty message + +Revision ID: 3f3b01817d48 +Revises: ab4344121689 +Create Date: 2020-10-21 21:10:08.759112 + +""" +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = '3f3b01817d48' +down_revision = 'ab4344121689' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('fleet_time') + op.drop_table('fleet_time_by_hull') + op.create_table('fleet_time_by_day_hull', + sa.Column('character_id', sa.Integer(), nullable=False), + sa.Column('hull_type', sa.Integer(), nullable=False), + sa.Column('day', sa.Date(), nullable=False), + sa.Column('duration', sa.Integer(), server_default='0', nullable=False), + sa.ForeignKeyConstraint(['character_id'], ['characters.id'], name=op.f('fk_fleet_time_by_day_hull_character_id_characters'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['hull_type'], ['invtypes.type_id'], name=op.f('fk_fleet_time_by_day_hull_hull_type_invtypes'), onupdate='CASCADE'), + sa.PrimaryKeyConstraint('character_id', 'hull_type', 'day', name=op.f('pk_fleet_time_by_day_hull')) + ) + op.create_table('fleet_wing_mapping', + sa.Column('fleet_id', sa.BigInteger(), nullable=False), + sa.Column('waitlist_id', sa.Integer(), nullable=False), + sa.Column('wing_id', sa.BigInteger(), nullable=True), + sa.Column('squad_id', sa.BigInteger(), nullable=True), + sa.ForeignKeyConstraint(['fleet_id'], ['crest_fleets.fleet_id'], name=op.f('fk_fleet_wing_mapping_fleet_id_crest_fleets'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['waitlist_id'], ['waitlists.id'], name=op.f('fk_fleet_wing_mapping_waitlist_id_waitlists'), onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('fleet_id', 'waitlist_id', name=op.f('pk_fleet_wing_mapping')) + ) + op.drop_column('crest_fleets', 'sniper_wing_id') + op.drop_column('crest_fleets', 'sniper_squad_id') + op.drop_column('crest_fleets', 'other_squad_id') + op.drop_column('crest_fleets', 'other_wing_id') + op.drop_column('crest_fleets', 'logi_squad_id') + op.drop_column('crest_fleets', 'logi_wing_id') + op.drop_column('crest_fleets', 'dps_squad_id') + op.drop_column('crest_fleets', 'dps_wing_id') + op.add_column('fleet_time_last_tracked', sa.Column('last_time_tracked', sa.DateTime(), nullable=False)) + op.drop_column('fleet_time_last_tracked', 'fleet_time_last_tracked') + op.alter_column('waitlist_groups', 'queueID', + existing_type=sa.Integer(display_width=11), + nullable=True) + op.drop_constraint('fk_waitlist_groups_queueID_waitlists', 'waitlist_groups', type_='foreignkey') + op.create_foreign_key(op.f('fk_waitlist_groups_queueID_waitlists'), 'waitlist_groups', 'waitlists', ['queueID'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + op.add_column('waitlists', sa.Column('ordering', sa.Integer(), nullable=False)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('waitlists', 'ordering') + op.drop_constraint(op.f('fk_waitlist_groups_queueID_waitlists'), 'waitlist_groups', type_='foreignkey') + op.create_foreign_key('fk_waitlist_groups_queueID_waitlists', 'waitlist_groups', 'waitlists', ['queueID'], ['id']) + op.alter_column('waitlist_groups', 'queueID', + existing_type=sa.Integer(display_width=11), + nullable=False) + op.add_column('fleet_time_last_tracked', sa.Column('fleet_time_last_tracked', sa.DateTime(), nullable=False)) + op.drop_column('fleet_time_last_tracked', 'last_time_tracked') + op.add_column('crest_fleets', sa.Column('dps_wing_id', sa.BigInteger(display_width=20), autoincrement=False, nullable=True)) + op.add_column('crest_fleets', sa.Column('dps_squad_id', sa.BigInteger(display_width=20), autoincrement=False, nullable=True)) + op.add_column('crest_fleets', sa.Column('logi_wing_id', sa.BigInteger(display_width=20), autoincrement=False, nullable=True)) + op.add_column('crest_fleets', sa.Column('logi_squad_id', sa.BigInteger(display_width=20), autoincrement=False, nullable=True)) + op.add_column('crest_fleets', sa.Column('other_wing_id', sa.BigInteger(display_width=20), autoincrement=False, nullable=True)) + op.add_column('crest_fleets', sa.Column('other_squad_id', sa.BigInteger(display_width=20), autoincrement=False, nullable=True)) + op.add_column('crest_fleets', sa.Column('sniper_squad_id', sa.BigInteger(display_width=20), autoincrement=False, nullable=True)) + op.add_column('crest_fleets', sa.Column('sniper_wing_id', sa.BigInteger(display_width=20), autoincrement=False, nullable=True)) + op.drop_table('fleet_wing_mapping') + op.drop_table('fleet_time_by_day_hull') + op.create_table('fleet_time_by_hull', + sa.Column('character_id', sa.Integer(display_width=11), autoincrement=False, nullable=False), + sa.Column('hull_type', sa.Integer(display_width=11), autoincrement=False, nullable=False), + sa.Column('duration', sa.Integer(display_width=11), server_default=sa.text('0'), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['character_id'], ['characters.id'], name='fk_fleet_time_by_hull_character_id_characters', onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['hull_type'], ['invtypes.type_id'], name='fk_fleet_time_by_hull_hull_type_invtypes', onupdate='CASCADE'), + sa.PrimaryKeyConstraint('character_id', 'hull_type') + ) + op.create_table('fleet_time', + sa.Column('character_id', sa.Integer(display_width=11), autoincrement=False, nullable=False), + sa.Column('duration', sa.Integer(display_width=11), server_default=sa.text('0'), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['character_id'], ['characters.id'], name='fk_fleet_time_character_id_characters', onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('character_id') + ) + # ### end Alembic commands ###