Vetsi sada zmen

This commit is contained in:
Michal Kváček
2023-08-21 22:45:33 +02:00
parent 33e0a35f4b
commit 9314d31186
22 changed files with 352 additions and 201 deletions
@@ -0,0 +1,28 @@
"""add seats to aircraft
Revision ID: 71d100e65f04
Revises: dd48d8dab743
Create Date: 2023-08-16 06:46:02.618843
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '71d100e65f04'
down_revision = 'dd48d8dab743'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('aircraft', sa.Column('seats', sa.Integer(), nullable=False))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('aircraft', 'seats')
# ### end Alembic commands ###
@@ -0,0 +1,38 @@
"""make flight-copilot M:N relationship
Revision ID: 434066bcb25d
Revises: 71d100e65f04
Create Date: 2023-08-16 07:03:50.599364
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '434066bcb25d'
down_revision = '71d100e65f04'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('flight_has_copilot',
sa.Column('flight_id', sa.Integer(), nullable=False),
sa.Column('copilot_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['copilot_id'], ['copilot.id'], ),
sa.ForeignKeyConstraint(['flight_id'], ['flight.id'], ),
sa.PrimaryKeyConstraint('flight_id', 'copilot_id')
)
op.drop_constraint('flight_ibfk_2', 'flight', type_='foreignkey')
op.drop_column('flight', 'copilot_id')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('flight', sa.Column('copilot_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
op.create_foreign_key('flight_ibfk_2', 'flight', 'copilot', ['copilot_id'], ['id'])
op.drop_table('flight_has_copilot')
# ### end Alembic commands ###
@@ -0,0 +1,42 @@
"""rename columns with weather
Revision ID: 5c43394aa8e0
Revises: 434066bcb25d
Create Date: 2023-08-16 16:31:36.204608
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '5c43394aa8e0'
down_revision = '434066bcb25d'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('flight', sa.Column('takeoff_weather_info_id', sa.Integer(), nullable=True))
op.add_column('flight', sa.Column('landing_weather_info_id', sa.Integer(), nullable=True))
op.drop_constraint('flight_ibfk_6', 'flight', type_='foreignkey')
op.drop_constraint('flight_ibfk_7', 'flight', type_='foreignkey')
op.create_foreign_key(None, 'flight', 'weather_info', ['takeoff_weather_info_id'], ['id'])
op.create_foreign_key(None, 'flight', 'weather_info', ['landing_weather_info_id'], ['id'])
op.drop_column('flight', 'weather_info_landing_id')
op.drop_column('flight', 'weather_info_takeoff_id')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('flight', sa.Column('weather_info_takeoff_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
op.add_column('flight', sa.Column('weather_info_landing_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
op.drop_constraint(None, 'flight', type_='foreignkey')
op.drop_constraint(None, 'flight', type_='foreignkey')
op.create_foreign_key('flight_ibfk_7', 'flight', 'weather_info', ['weather_info_takeoff_id'], ['id'])
op.create_foreign_key('flight_ibfk_6', 'flight', 'weather_info', ['weather_info_landing_id'], ['id'])
op.drop_column('flight', 'landing_weather_info_id')
op.drop_column('flight', 'takeoff_weather_info_id')
# ### end Alembic commands ###