def upgrade():
    inspector = reflection.Inspector.from_engine(op.get_bind())
    foreign_keys = inspector.get_foreign_keys(TABLE_NAME)
    migration.remove_foreign_keys(TABLE_NAME, foreign_keys)

    unique_constraints = inspector.get_unique_constraints(TABLE_NAME)
    for constraint in unique_constraints:
        op.drop_constraint(
            constraint_name=constraint['name'],
            table_name=TABLE_NAME,
            type_="unique"
        )

    op.create_unique_constraint(
        constraint_name=('uniq_port_forwardings0floatingip_id0'
                         'external_port0protocol'),
        table_name=TABLE_NAME,
        columns=['floatingip_id', 'external_port', 'protocol']
    )
    op.create_unique_constraint(
        constraint_name=('uniq_port_forwardings0internal_neutron_port_id0'
                         'socket0protocol'),
        table_name=TABLE_NAME,
        columns=['internal_neutron_port_id', 'socket', 'protocol']
    )

    migration.create_foreign_keys(TABLE_NAME, foreign_keys)
예제 #2
0
def upgrade():
    op.add_column(PF_TABLE_NAME,
                  sa.Column('internal_ip_address', sa.String(length=64),
                            nullable=False))
    op.add_column(PF_TABLE_NAME, sa.Column('internal_port_start', sa.Integer(),
                  nullable=False))
    op.add_column(PF_TABLE_NAME, sa.Column('internal_port_end', sa.Integer(),
                  nullable=False))
    op.add_column(PF_TABLE_NAME, sa.Column('external_port_start', sa.Integer(),
                  nullable=False))
    op.add_column(PF_TABLE_NAME, sa.Column('external_port_end', sa.Integer(),
                  nullable=False))

    foreign_keys = clear_constraints_and_foreign()
    migrate_values()
    op.create_unique_constraint(
        columns=['floatingip_id', 'protocol',
                 'external_port_start', 'external_port_end'],
        constraint_name='uniq_port_forwardings0floatingip_id0protocol0'
                        'external_ports',
        table_name=PF_TABLE_NAME)

    op.create_unique_constraint(
        columns=['protocol', 'internal_neutron_port_id', 'internal_ip_address',
                 'internal_port_start', 'internal_port_end'],
        constraint_name='uniq_port_forwardings0ptcl0in_prt_id0in_ip_addr0'
                        'in_prts',
        table_name=PF_TABLE_NAME)

    op.drop_column(PF_TABLE_NAME, 'socket')

    op.drop_column(PF_TABLE_NAME, 'external_port')

    migration.create_foreign_keys(PF_TABLE_NAME, foreign_keys)
예제 #3
0
def upgrade():
    inspector = sqlalchemy.inspect(op.get_bind())
    fk_constraints = inspector.get_foreign_keys(TABLE_NAME)
    for fk in fk_constraints:
        fk['options']['ondelete'] = 'CASCADE'

    migration.remove_foreign_keys(TABLE_NAME, fk_constraints)
    migration.create_foreign_keys(TABLE_NAME, fk_constraints)
def upgrade():
    inspector = reflection.Inspector.from_engine(op.get_bind())
    fk_constraints = inspector.get_foreign_keys(TABLE_NAME)
    for fk in fk_constraints:
        fk['options']['ondelete'] = 'CASCADE'

    migration.remove_foreign_keys(TABLE_NAME, fk_constraints)
    migration.create_foreign_keys(TABLE_NAME, fk_constraints)
def upgrade():
    inspector = reflection.Inspector.from_engine(op.get_bind())
    fk_constraints = inspector.get_foreign_keys(TABLE_NAME)
    for fk in fk_constraints:
        fk['options']['ondelete'] = 'CASCADE'

    migration.remove_foreign_keys(TABLE_NAME, fk_constraints)
    migration.create_foreign_keys(TABLE_NAME, fk_constraints)
def upgrade():
    inspector = reflection.Inspector.from_engine(op.get_bind())

    fks_to_cascade = {
        'sfc_flow_classifier_l7_parameters': 'classifier_id',
        'sfc_chain_group_associations': 'portchain_id',
        'sfc_port_chain_parameters': 'chain_id',
        'sfc_service_function_params': 'pair_id',
        'sfc_chain_classifier_associations': 'portchain_id'
    }

    for table, column in fks_to_cascade.items():
        fk_constraints = inspector.get_foreign_keys(table)
        for fk in fk_constraints:
            if column in fk['constrained_columns']:
                fk['options']['ondelete'] = 'CASCADE'
                migration.remove_foreign_keys(table, fk_constraints)
                migration.create_foreign_keys(table, fk_constraints)
def upgrade():
    inspector = reflection.Inspector.from_engine(op.get_bind())

    fks_to_cascade = {
        "sfc_flow_classifier_l7_parameters": "classifier_id",
        "sfc_chain_group_associations": "portchain_id",
        "sfc_port_chain_parameters": "chain_id",
        "sfc_service_function_params": "pair_id",
        "sfc_chain_classifier_associations": "portchain_id",
    }

    for table, column in fks_to_cascade.items():
        fk_constraints = inspector.get_foreign_keys(table)
        for fk in fk_constraints:
            if column in fk["constrained_columns"]:
                fk["options"]["ondelete"] = "CASCADE"
                migration.remove_foreign_keys(table, fk_constraints)
                migration.create_foreign_keys(table, fk_constraints)
def upgrade():
    inspector = reflection.Inspector.from_engine(op.get_bind())

    fks_to_cascade = {
        'sfc_flow_classifier_l7_parameters': 'classifier_id',
        'sfc_chain_group_associations': 'portchain_id',
        'sfc_port_chain_parameters': 'chain_id',
        'sfc_service_function_params': 'pair_id',
        'sfc_chain_classifier_associations': 'portchain_id'
    }

    for table, column in fks_to_cascade.items():
        fk_constraints = inspector.get_foreign_keys(table)
        for fk in fk_constraints:
            if column in fk['constrained_columns']:
                fk['options']['ondelete'] = 'CASCADE'
                migration.remove_foreign_keys(table, fk_constraints)
                migration.create_foreign_keys(table, fk_constraints)
def upgrade():
    inspector = sa.inspect(op.get_bind())
    foreign_keys = inspector.get_foreign_keys(TABLE_NAME)
    migration.remove_foreign_keys(TABLE_NAME, foreign_keys)

    unique_constraints = inspector.get_unique_constraints(TABLE_NAME)
    for constraint in unique_constraints:
        op.drop_constraint(constraint_name=constraint['name'],
                           table_name=TABLE_NAME,
                           type_="unique")

    op.create_unique_constraint(
        constraint_name=('uniq_port_forwardings0floatingip_id0'
                         'external_port0protocol'),
        table_name=TABLE_NAME,
        columns=['floatingip_id', 'external_port', 'protocol'])
    op.create_unique_constraint(
        constraint_name=('uniq_port_forwardings0internal_neutron_port_id0'
                         'socket0protocol'),
        table_name=TABLE_NAME,
        columns=['internal_neutron_port_id', 'socket', 'protocol'])

    migration.create_foreign_keys(TABLE_NAME, foreign_keys)
def upgrade():
    inspector = reflection.Inspector.from_engine(op.get_bind())
    fk_constraints = inspector.get_foreign_keys(TABLE_NAME)
    migration.remove_foreign_keys(TABLE_NAME, fk_constraints)
    migration.create_foreign_keys(TABLE_NAME, fk_constraints)
def upgrade():
    inspector = reflection.Inspector.from_engine(op.get_bind())
    fk_constraints = inspector.get_foreign_keys(TABLE_NAME)
    migration.remove_foreign_keys(TABLE_NAME, fk_constraints)
    migration.create_foreign_keys(TABLE_NAME, fk_constraints)