Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def upgrade():
op.drop_constraint(fk_name, "featurecohort_feature", type_="foreignkey")
op.create_foreign_key(
op.f(fk_name),
"featurecohort_feature",
"feature",
["feature_id"],
["id"],
ondelete="cascade",
)
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key('order_ibfk_1', 'order', 'user', ['courrier_id'], ['id'])
### end Alembic commands ###
op.drop_constraint(
op.f('groups_tenants_role_id_fkey'),
'groups_tenants',
type_='foreignkey')
op.drop_constraint(
op.f('groups_tenants_group_id_fkey'),
'groups_tenants',
type_='foreignkey')
op.drop_constraint(
op.f('groups_tenants_tenant_id_fkey'),
'groups_tenants',
type_='foreignkey')
op.create_foreign_key(u'groups_tenants_role_id_fkey', 'groups_tenants',
'roles', ['role_id'], ['id'])
op.create_foreign_key(u'groups_tenants_tenant_id_fkey', 'groups_tenants',
'tenants', ['tenant_id'], ['id'])
op.create_foreign_key(u'groups_tenants_group_id_fkey', 'groups_tenants',
'groups', ['group_id'], ['id'])
# set null=false
op.alter_column(
'groups_tenants',
'role_id',
existing_type=sa.INTEGER(),
nullable=False)
# dep_up blueprint fks
op.drop_constraint(
op.f('deployment_updates__new_blueprint_fk_fkey'),
'deployment_updates',
type_='foreignkey')
remote_cols=["resource_id"],
local_cols=["resource_id"],
onupdate="CASCADE",
ondelete="CASCADE",
)
if "resources_pkey" == insp.get_pk_constraint("resources")["name"]:
op.execute("ALTER INDEX resources_pkey RENAME to pk_resources")
if "resources_owner_group_id_fkey" in [
c["name"] for c in insp.get_foreign_keys("resources")
]:
op.drop_constraint(
"resources_owner_group_id_fkey", "resources", type_="foreignkey"
)
op.create_foreign_key(
None,
"resources",
"groups",
remote_cols=["id"],
local_cols=["owner_group_id"],
onupdate="CASCADE",
ondelete="SET NULL",
)
if "resources_owner_user_id_fkey" in [
c["name"] for c in insp.get_foreign_keys("resources")
]:
op.drop_constraint(
"resources_owner_user_id_fkey", "resources", type_="foreignkey"
)
op.create_foreign_key(
def upgrade():
partitions = (
'tags', 'resources', 'resource_properties', 'issues', 'resource_mappings',
'issue_properties', 'auditlog', 'logs', 'emails'
)
for table in partitions:
op.execute('ALTER TABLE `{}` REMOVE PARTITIONING'.format(table))
# ### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key('fk_resource_mapping_child', 'resource_mappings', 'resources', ['child'], ['resource_id'], ondelete='CASCADE')
op.create_foreign_key('fk_resource_mapping_parent', 'resource_mappings', 'resources', ['parent'], ['resource_id'], ondelete='CASCADE')
op.create_foreign_key('fk_resource_property_resource_id', 'resource_properties', 'resources', ['resource_id'], ['resource_id'], ondelete='CASCADE')
op.create_foreign_key('fk_resource_account_id', 'resources', 'accounts', ['account_id'], ['account_id'], ondelete='CASCADE')
op.create_foreign_key('fk_resource_types_resource_type_id', 'resources', 'resource_types', ['resource_type_id'], ['resource_type_id'], ondelete='CASCADE')
op.create_foreign_key('fk_tag_resource_id', 'tags', 'resources', ['resource_id'], ['resource_id'], ondelete='CASCADE')
# ### end Alembic commands ###
def upgrade():
op.execute('ALTER TABLE roombooking.reservations ALTER COLUMN booked_for_id TYPE int USING booked_for_id::int')
op.create_foreign_key(None,
'reservations', 'users',
['booked_for_id'], ['id'],
source_schema='roombooking', referent_schema='users')
op.create_index(None, 'reservations', ['booked_for_id'], unique=False, schema='roombooking')
['report_id'], ['id'])
drop_constraint('reportunknownpackages_report_id_fkey', 'reportunknownpackages', type_='foreignkey')
create_foreign_key('reportunknownpackages_report_id_fkey', 'reportunknownpackages', 'reports',
['report_id'], ['id'])
drop_constraint('reportselinuxmodes_report_id_fkey', 'reportselinuxmodes', type_='foreignkey')
create_foreign_key('reportselinuxmodes_report_id_fkey', 'reportselinuxmodes', 'reports',
['report_id'], ['id'])
drop_constraint('reportselinuxcontexts_report_id_fkey', 'reportselinuxcontexts', type_='foreignkey')
create_foreign_key('reportselinuxcontexts_report_id_fkey', 'reportselinuxcontexts', 'reports',
['report_id'], ['id'])
drop_constraint('reportreleasedesktops_report_id_fkey', 'reportreleasedesktops', type_='foreignkey')
create_foreign_key('reportreleasedesktops_report_id_fkey', 'reportreleasedesktops', 'reports',
['report_id'], ['id'])
drop_constraint('reportreasons_report_id_fkey', 'reportreasons', type_='foreignkey')
create_foreign_key('reportreasons_report_id_fkey', 'reportreasons', 'reports',
['report_id'], ['id'])
drop_constraint('reportraw_report_id_fkey', 'reportraw', type_='foreignkey')
create_foreign_key('reportraw_report_id_fkey', 'reportraw', 'reports',
['report_id'], ['id'])
drop_constraint('reportpackages_report_id_fkey', 'reportpackages', type_='foreignkey')
create_foreign_key('reportpackages_report_id_fkey', 'reportpackages', 'reports',
['report_id'], ['id'])
drop_constraint('reportopsysreleases_report_id_fkey', 'reportopsysreleases', type_='foreignkey')
create_foreign_key('reportopsysreleases_report_id_fkey', 'reportopsysreleases', 'reports',
op.alter_column('permission', 'resource_type', type_=tmp_type,
existing_type=old_type)
meta = sa.MetaData()
meta.bind = bind
meta.reflect()
permission = meta.tables['permission']
q = sa.update(permission).where(permission.c.resource_type == 'watchlist')
q = q.values(resource_type='collection')
op.execute(q)
old_type.drop(bind, checkfirst=False)
new_type.create(bind, checkfirst=False)
op.execute('ALTER TABLE permission ALTER COLUMN resource_type TYPE permission_type'
' USING resource_type::text::permission_type;')
tmp_type.drop(bind, checkfirst=False)
op.create_foreign_key("collection_creator_id_fkey", "collection", "role",
["creator_id"], ["id"])
op.create_foreign_key("entity_collection_id_fkey", "entity", "collection",
["collection_id"], ["id"])
'fifo',
'{}'::jsonb
);
INSERT INTO sgroups_for_domains
VALUES ('default', 'default');
'''
connection = op.get_bind()
connection.execute(query)
op.add_column('agents', sa.Column('scaling_group', sa.String(length=64), server_default='default', nullable=False))
op.create_index(op.f('ix_agents_scaling_group'), 'agents', ['scaling_group'], unique=False)
op.create_foreign_key(op.f('fk_agents_scaling_group_scaling_groups'),
'agents', 'scaling_groups', ['scaling_group'], ['name'])
op.add_column('kernels', sa.Column('scaling_group', sa.String(length=64), server_default='default', nullable=False))
op.create_index(op.f('ix_kernels_scaling_group'), 'kernels', ['scaling_group'], unique=False)
op.create_foreign_key(op.f('fk_kernels_scaling_group_scaling_groups'), 'kernels', 'scaling_groups', ['scaling_group'], ['name'])
# ### end Alembic commands ###
def upgrade():
op.create_foreign_key(name="fk_vmmaster_log_step_to_session",
source="vmmaster_log_steps",
referent="sessions",
local_cols=["session_id"],
remote_cols=["id"],
ondelete='CASCADE')
op.create_foreign_key(name="fk_session_log_step_to_vmmaster_log_step",
source="session_log_steps",
referent="vmmaster_log_steps",
local_cols=["vmmaster_log_step_id"],
remote_cols=["id"],
ondelete='CASCADE')