draft: crud pro planovac

This commit is contained in:
Michal Kváček
2024-03-25 19:04:24 +01:00
parent 01f8a616bf
commit 63e2eed8c2
8 changed files with 150 additions and 21 deletions
@@ -0,0 +1,38 @@
"""make markers in flight planner separate table
Revision ID: de70fc471699
Revises: 7a3738a805c5
Create Date: 2024-03-24 21:55:12.307588
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = 'de70fc471699'
down_revision = '7a3738a805c5'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('flight_plan_marker',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('flight_plan_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=False),
sa.Column('gps_latitude', sa.Float(), nullable=True),
sa.Column('gps_longitude', sa.Float(), nullable=True),
sa.ForeignKeyConstraint(['flight_plan_id'], ['flight_plan.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_column('flight_plan', 'markers')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('flight_plan', sa.Column('markers', mysql.LONGTEXT(charset='utf8mb4', collation='utf8mb4_bin'), nullable=False))
op.drop_table('flight_plan_marker')
# ### end Alembic commands ###
@@ -0,0 +1,42 @@
"""add type and position to flight_plan_marker
Revision ID: 70152c47cb49
Revises: de70fc471699
Create Date: 2024-03-24 22:00:35.234920
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '70152c47cb49'
down_revision = 'de70fc471699'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('flight_plan_marker', sa.Column('type', sa.String(length=64), nullable=False))
op.add_column('flight_plan_marker', sa.Column('position', sa.Integer(), nullable=False))
op.alter_column('flight_plan_marker', 'gps_latitude',
existing_type=mysql.FLOAT(),
nullable=False)
op.alter_column('flight_plan_marker', 'gps_longitude',
existing_type=mysql.FLOAT(),
nullable=False)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('flight_plan_marker', 'gps_longitude',
existing_type=mysql.FLOAT(),
nullable=True)
op.alter_column('flight_plan_marker', 'gps_latitude',
existing_type=mysql.FLOAT(),
nullable=True)
op.drop_column('flight_plan_marker', 'position')
op.drop_column('flight_plan_marker', 'type')
# ### end Alembic commands ###