kopia lustrzana https://github.com/glidernet/ogn-python
Massive scheme modifications requires a new database
rodzic
52c9df4f5e
commit
9261e99cbf
|
@ -1,76 +0,0 @@
|
|||
"""Remove non position fields from AircraftBeacon and ReceiverBeacon
|
||||
|
||||
Revision ID: 079fe885ae20
|
||||
Revises: 6c19cedf5fa7
|
||||
Create Date: 2019-09-25 21:42:34.924732
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '079fe885ae20'
|
||||
down_revision = '6c19cedf5fa7'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_constraint('aircraft_beacons_receiver_id_fkey', 'aircraft_beacons', type_='foreignkey')
|
||||
op.drop_constraint('aircraft_beacons_device_id_fkey', 'aircraft_beacons', type_='foreignkey')
|
||||
op.drop_column('aircraft_beacons', 'device_id')
|
||||
op.drop_column('aircraft_beacons', 'receiver_id')
|
||||
|
||||
op.drop_constraint('receiver_beacons_receiver_id_fkey', 'receiver_beacons', type_='foreignkey')
|
||||
op.drop_column('receiver_beacons', 'receiver_id')
|
||||
|
||||
op.drop_column('receiver_beacons', 'total_ram')
|
||||
op.drop_column('receiver_beacons', 'senders_visible')
|
||||
op.drop_column('receiver_beacons', 'senders_messages')
|
||||
op.drop_column('receiver_beacons', 'cpu_temp')
|
||||
op.drop_column('receiver_beacons', 'platform')
|
||||
op.drop_column('receiver_beacons', 'rec_input_noise')
|
||||
op.drop_column('receiver_beacons', 'ntp_error')
|
||||
op.drop_column('receiver_beacons', 'good_senders')
|
||||
op.drop_column('receiver_beacons', 'senders_total')
|
||||
op.drop_column('receiver_beacons', 'cpu_load')
|
||||
op.drop_column('receiver_beacons', 'free_ram')
|
||||
op.drop_column('receiver_beacons', 'good_and_bad_senders')
|
||||
op.drop_column('receiver_beacons', 'amperage')
|
||||
op.drop_column('receiver_beacons', 'voltage')
|
||||
op.drop_column('receiver_beacons', 'senders_signal')
|
||||
op.drop_column('receiver_beacons', 'version')
|
||||
op.drop_column('receiver_beacons', 'relay')
|
||||
op.drop_column('receiver_beacons', 'rt_crystal_correction')
|
||||
op.drop_column('receiver_beacons', 'good_senders_signal')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.add_column('receiver_beacons', sa.Column('receiver_id', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.create_foreign_key('receiver_beacons_receiver_id_fkey', 'receiver_beacons', 'receivers', ['receiver_id'], ['id'], ondelete='SET NULL')
|
||||
|
||||
op.add_column('receiver_beacons', sa.Column('good_senders_signal', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('rt_crystal_correction', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('relay', sa.VARCHAR(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('version', sa.VARCHAR(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('senders_signal', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('voltage', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('amperage', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('good_and_bad_senders', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('free_ram', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('cpu_load', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('senders_total', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('good_senders', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('ntp_error', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('rec_input_noise', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('platform', sa.VARCHAR(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('cpu_temp', sa.REAL(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('senders_messages', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('senders_visible', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.add_column('receiver_beacons', sa.Column('total_ram', sa.REAL(), autoincrement=False, nullable=True))
|
||||
|
||||
op.add_column('aircraft_beacons', sa.Column('receiver_id', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.add_column('aircraft_beacons', sa.Column('device_id', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.create_foreign_key('aircraft_beacons_device_id_fkey', 'aircraft_beacons', 'devices', ['device_id'], ['id'], ondelete='SET NULL')
|
||||
op.create_foreign_key('aircraft_beacons_receiver_id_fkey', 'aircraft_beacons', 'receivers', ['receiver_id'], ['id'], ondelete='SET NULL')
|
|
@ -1,76 +0,0 @@
|
|||
"""Use Enum for AircraftType
|
||||
|
||||
Revision ID: 6c19cedf5fa7
|
||||
Revises: be9a6dad551e
|
||||
Create Date: 2019-09-24 18:37:40.224279
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6c19cedf5fa7'
|
||||
down_revision = 'be9a6dad551e'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
aircrafttype = postgresql.ENUM('UNKNOWN', 'GLIDER_OR_MOTOR_GLIDER', 'TOW_TUG_PLANE', 'HELICOPTER_ROTORCRAFT',
|
||||
'PARACHUTE', 'DROP_PLANE', 'HANG_GLIDER', 'PARA_GLIDER', 'POWERED_AIRCRAFT',
|
||||
'JET_AIRCRAFT', 'FLYING_SAUCER', 'BALLOON', 'AIRSHIP', 'UNMANNED_AERIAL_VEHICLE',
|
||||
'STATIC_OBJECT', name='aircrafttype')
|
||||
|
||||
def upgrade():
|
||||
aircrafttype.create(op.get_bind())
|
||||
|
||||
for table in ['aircraft_beacons', 'devices']:
|
||||
op.add_column(table, sa.Column('aircraft_type_enum', sa.Enum(
|
||||
'UNKNOWN', 'GLIDER_OR_MOTOR_GLIDER', 'TOW_TUG_PLANE', 'HELICOPTER_ROTORCRAFT',
|
||||
'PARACHUTE', 'DROP_PLANE', 'HANG_GLIDER', 'PARA_GLIDER', 'POWERED_AIRCRAFT',
|
||||
'JET_AIRCRAFT', 'FLYING_SAUCER', 'BALLOON', 'AIRSHIP', 'UNMANNED_AERIAL_VEHICLE',
|
||||
'STATIC_OBJECT', name='aircrafttype'), nullable=False, server_default='UNKNOWN'))
|
||||
op.execute("""
|
||||
UPDATE {table} SET aircraft_type_enum = 'UNKNOWN' WHERE aircraft_type = 0;
|
||||
UPDATE {table} SET aircraft_type_enum = 'GLIDER_OR_MOTOR_GLIDER' WHERE aircraft_type = 1;
|
||||
UPDATE {table} SET aircraft_type_enum = 'TOW_TUG_PLANE' WHERE aircraft_type = 2;
|
||||
UPDATE {table} SET aircraft_type_enum = 'HELICOPTER_ROTORCRAFT' WHERE aircraft_type = 3;
|
||||
UPDATE {table} SET aircraft_type_enum = 'PARACHUTE' WHERE aircraft_type = 4;
|
||||
UPDATE {table} SET aircraft_type_enum = 'DROP_PLANE' WHERE aircraft_type = 5;
|
||||
UPDATE {table} SET aircraft_type_enum = 'HANG_GLIDER' WHERE aircraft_type = 6;
|
||||
UPDATE {table} SET aircraft_type_enum = 'PARA_GLIDER' WHERE aircraft_type = 7;
|
||||
UPDATE {table} SET aircraft_type_enum = 'POWERED_AIRCRAFT' WHERE aircraft_type = 8;
|
||||
UPDATE {table} SET aircraft_type_enum = 'JET_AIRCRAFT' WHERE aircraft_type = 9;
|
||||
UPDATE {table} SET aircraft_type_enum = 'FLYING_SAUCER' WHERE aircraft_type = 10;
|
||||
UPDATE {table} SET aircraft_type_enum = 'BALLOON' WHERE aircraft_type = 11;
|
||||
UPDATE {table} SET aircraft_type_enum = 'AIRSHIP' WHERE aircraft_type = 12;
|
||||
UPDATE {table} SET aircraft_type_enum = 'UNMANNED_AERIAL_VEHICLE' WHERE aircraft_type = 13;
|
||||
UPDATE {table} SET aircraft_type_enum = 'STATIC_OBJECT' WHERE aircraft_type = 15;
|
||||
""".format(table=table))
|
||||
op.drop_column(table, 'aircraft_type')
|
||||
op.alter_column(table, 'aircraft_type_enum', new_column_name='aircraft_type')
|
||||
|
||||
def downgrade():
|
||||
for table in ['aircraft_beacons', 'devices']:
|
||||
op.add_column(table, sa.Column('aircraft_type_int', sa.SmallInteger))
|
||||
op.execute("""
|
||||
UPDATE {table} SET aircraft_type_int = 0 WHERE aircraft_type = 'UNKNOWN';
|
||||
UPDATE {table} SET aircraft_type_int = 1 WHERE aircraft_type = 'GLIDER_OR_MOTOR_GLIDER';
|
||||
UPDATE {table} SET aircraft_type_int = 2 WHERE aircraft_type = 'TOW_TUG_PLANE';
|
||||
UPDATE {table} SET aircraft_type_int = 3 WHERE aircraft_type = 'HELICOPTER_ROTORCRAFT';
|
||||
UPDATE {table} SET aircraft_type_int = 4 WHERE aircraft_type = 'PARACHUTE';
|
||||
UPDATE {table} SET aircraft_type_int = 5 WHERE aircraft_type = 'DROP_PLANE';
|
||||
UPDATE {table} SET aircraft_type_int = 6 WHERE aircraft_type = 'HANG_GLIDER';
|
||||
UPDATE {table} SET aircraft_type_int = 7 WHERE aircraft_type = 'PARA_GLIDER';
|
||||
UPDATE {table} SET aircraft_type_int = 8 WHERE aircraft_type = 'POWERED_AIRCRAFT';
|
||||
UPDATE {table} SET aircraft_type_int = 9 WHERE aircraft_type = 'JET_AIRCRAFT';
|
||||
UPDATE {table} SET aircraft_type_int = 10 WHERE aircraft_type = 'FLYING_SAUCER';
|
||||
UPDATE {table} SET aircraft_type_int = 11 WHERE aircraft_type = 'BALLOON';
|
||||
UPDATE {table} SET aircraft_type_int = 12 WHERE aircraft_type = 'AIRSHIP';
|
||||
UPDATE {table} SET aircraft_type_int = 13 WHERE aircraft_type = 'UNMANNED_AERIAL_VEHICLE';
|
||||
UPDATE {table} SET aircraft_type_int = 15 WHERE aircraft_type = 'STATIC_OBJECT';
|
||||
""".format(table=table))
|
||||
op.drop_column(table, 'aircraft_type')
|
||||
op.alter_column(table, 'aircraft_type_int', new_column_name='aircraft_type')
|
||||
|
||||
aircrafttype.drop(op.get_bind())
|
|
@ -1,28 +0,0 @@
|
|||
"""Remove FK relation from device to device_info
|
||||
|
||||
Revision ID: 885123e6a2d6
|
||||
Revises: 002656878233
|
||||
Create Date: 2019-04-27 14:22:30.841969
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '885123e6a2d6'
|
||||
down_revision = '002656878233'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_index('ix_device_infos_device_id', table_name='device_infos')
|
||||
op.drop_constraint('device_infos_device_id_fkey', 'device_infos', type_='foreignkey')
|
||||
op.drop_column('device_infos', 'device_id')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.add_column('device_infos', sa.Column('device_id', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.create_foreign_key('device_infos_device_id_fkey', 'device_infos', 'devices', ['device_id'], ['id'], ondelete='SET NULL')
|
||||
op.create_index('ix_device_infos_device_id', 'device_infos', ['device_id'], unique=False)
|
|
@ -1,41 +0,0 @@
|
|||
"""Use Enums for DeviceInfoOrigin
|
||||
|
||||
Revision ID: be9a6dad551e
|
||||
Revises: 885123e6a2d6
|
||||
Create Date: 2019-09-15 14:38:25.838089
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'be9a6dad551e'
|
||||
down_revision = '885123e6a2d6'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
deviceinfoorigin = postgresql.ENUM('UNKNOWN', 'OGN_DDB', 'FLARMNET', 'USER_DEFINED', name='deviceinfoorigin')
|
||||
|
||||
def upgrade():
|
||||
deviceinfoorigin.create(op.get_bind())
|
||||
|
||||
op.add_column('device_infos', sa.Column('address_origin_enum', sa.Enum('UNKNOWN', 'OGN_DDB', 'FLARMNET', 'USER_DEFINED', name='deviceinfoorigin'), nullable=False, server_default='UNKNOWN'))
|
||||
op.execute("UPDATE device_infos SET address_origin_enum = 'UNKNOWN' WHERE address_origin = 0")
|
||||
op.execute("UPDATE device_infos SET address_origin_enum = 'OGN_DDB' WHERE address_origin = 1")
|
||||
op.execute("UPDATE device_infos SET address_origin_enum = 'FLARMNET' WHERE address_origin = 2")
|
||||
op.execute("UPDATE device_infos SET address_origin_enum = 'USER_DEFINED' WHERE address_origin = 3")
|
||||
op.drop_column('device_infos', 'address_origin')
|
||||
op.alter_column('device_infos', 'address_origin_enum', new_column_name='address_origin')
|
||||
|
||||
def downgrade():
|
||||
op.add_column('device_infos', sa.Column('address_origin_int', sa.SmallInteger))
|
||||
op.execute("UPDATE device_infos SET address_origin_int = 0 WHERE address_origin = 'UNKNOWN'")
|
||||
op.execute("UPDATE device_infos SET address_origin_int = 1 WHERE address_origin = 'OGN_DDB'")
|
||||
op.execute("UPDATE device_infos SET address_origin_int = 2 WHERE address_origin = 'FLARMNET'")
|
||||
op.execute("UPDATE device_infos SET address_origin_int = 3 WHERE address_origin = 'USER_DEFINED'")
|
||||
op.drop_column('device_infos', 'address_origin')
|
||||
op.alter_column('device_infos', 'address_origin_int', new_column_name='address_origin')
|
||||
|
||||
deviceinfoorigin.drop(op.get_bind())
|
Ładowanie…
Reference in New Issue