def upgrade():
op.execute(sa.schema.CreateSequence(sa.Sequence('pod_states_id_seq')))
op.add_column('pod_states', sa.Column('id', sa.Integer(), nullable=False,
server_default=sa.text("nextval('pod_states_id_seq'::regclass)")))
op.execute("ALTER TABLE pod_states DROP CONSTRAINT pod_states_pkey, "
"ADD CONSTRAINT pod_states_pkey PRIMARY KEY (id);")
op.add_column('container_states', sa.Column('exit_code', sa.Integer(), nullable=True))
op.add_column('container_states', sa.Column('pod_state_id', sa.Integer(), nullable=True))
op.add_column('container_states', sa.Column('reason', sa.Text(), nullable=True))
op.create_index('ix_pod_id_start_time', 'pod_states', ['pod_id', 'start_time'], unique=True)
op.create_foreign_key('container_states_pod_state_id_fkey', 'container_states',
'pod_states', ['pod_state_id'], ['id'])
upgrade_data()
op.alter_column('container_states', 'pod_state_id',
existing_type=sa.INTEGER(), nullable=False)
op.drop_constraint(u'container_states_pod_id_fkey', 'container_states',
type_='foreignkey')
op.drop_column('container_states', 'pod_id')
python类drop_constraint()的实例源码
2e00e70316c0_link_container_and_pod_states.py 文件源码
项目:kuberdock-platform
作者: cloudlinux
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
2e00e70316c0_link_container_and_pod_states.py 文件源码
项目:kuberdock-platform
作者: cloudlinux
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def downgrade():
op.add_column('container_states', sa.Column('pod_id', postgresql.UUID(),
autoincrement=False, nullable=True))
op.create_foreign_key(u'container_states_pod_id_fkey',
'container_states', 'pods', ['pod_id'], ['id'])
downgrade_data()
op.drop_column('container_states', 'reason')
op.drop_column('container_states', 'exit_code')
op.drop_constraint('container_states_pod_state_id_fkey', 'container_states',
type_='foreignkey')
op.drop_index('ix_pod_id_start_time', table_name='pod_states')
op.drop_column('container_states', 'pod_state_id')
op.execute("ALTER TABLE pod_states DROP CONSTRAINT pod_states_pkey, "
"ADD CONSTRAINT pod_states_pkey PRIMARY KEY (pod_id, start_time);")
op.drop_column('pod_states', 'id')
op.execute(sa.schema.DropSequence(sa.Sequence('pod_states_id_seq')))
18d04a76914f_billing_fixes.py 文件源码
项目:kuberdock-platform
作者: cloudlinux
项目源码
文件源码
阅读 27
收藏 0
点赞 0
评论 0
def upgrade():
op.alter_column('kubes', 'name', existing_type=sa.VARCHAR(length=64),
nullable=False)
op.create_index('one_default', 'kubes', ['is_default'], unique=True,
postgresql_where=sa.text(u'kubes.is_default IS true'))
op.drop_constraint(u'kubes_is_default_key', 'kubes', type_='unique')
op.alter_column('packages', 'name', existing_type=sa.VARCHAR(length=64),
nullable=False)
op.alter_column('packages', 'prefix', existing_type=sa.VARCHAR(),
nullable=False)
op.alter_column('packages', 'suffix', existing_type=sa.VARCHAR(),
nullable=False)
session = Session(bind=op.get_bind())
session.query(PackageKube).filter(sa.or_(
PackageKube.package_id.is_(None), PackageKube.kube_id.is_(None),
)).delete()
session.commit()
op.alter_column('package_kube', 'kube_id', existing_type=sa.INTEGER(),
nullable=False)
op.alter_column('package_kube', 'package_id', existing_type=sa.INTEGER(),
nullable=False)
241a7b04a9ff_add_menurole_rm_pages.py 文件源码
项目:kuberdock-platform
作者: cloudlinux
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('menuitem_roles',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('menuitem_id', sa.Integer(), nullable=True),
sa.Column('role_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['menuitem_id'], ['menus_items.id'], ),
sa.ForeignKeyConstraint(['role_id'], ['rbac_role.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_constraint(u'menus_created_by_id_fkey', 'menus', type_='foreignkey')
op.drop_column('menus', 'created_by_id')
op.drop_column('menus', 'ts')
op.drop_constraint(u'menus_items_created_by_id_fkey', 'menus_items', type_='foreignkey')
op.drop_constraint(u'menus_items_page_id_fkey', 'menus_items', type_='foreignkey')
op.drop_column('menus_items', 'created_by_id')
op.drop_column('menus_items', 'is_group_label')
op.drop_column('menus_items', 'page_id')
op.drop_column('menus_items', 'roles')
op.drop_column('menus_items', 'ts')
op.drop_column('menus_items', 'is_public')
op.drop_table('pages')
### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'mailing_list', type_='unique')
op.drop_column('mailing_list', 'url')
op.create_table('email',
sa.Column('id', sa.INTEGER(), server_default=sa.text(u"nextval('email_id_seq'::regclass)"), nullable=False),
sa.Column('value', sa.VARCHAR(length=120), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name=u'email_pkey'),
sa.UniqueConstraint('value', name=u'email_value_key'),
postgresql_ignore_search_path=False
)
op.create_table('email_mailing_list',
sa.Column('mailing_list_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('email_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['email_id'], [u'email.id'], name=u'email_mailing_list_email_id_fkey'),
sa.ForeignKeyConstraint(['mailing_list_id'], [u'mailing_list.id'], name=u'email_mailing_list_mailing_list_id_fkey')
)
# ### end Alembic commands ###
183533b82112_fix_callset_dbarray_mapping_individual_.py 文件源码
项目:GenomicsSampleAPIs
作者: Intel-HLS
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def downgrade():
# Drop trigger
op.execute(
'DROP TRIGGER increment_num_rows_in_db_array ON callset_to_db_array_association CASCADE')
op.drop_column(u'db_array', 'num_rows')
op.create_table(
'db_row',
sa.Column('id', sa.BIGINT(), nullable=False),
sa.Column('db_array_id', sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column('tile_row_id', sa.BIGINT(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['db_array_id'],[u'db_array.id'], name=u'db_row_db_array_id_fkey'),
sa.PrimaryKeyConstraint('id', name=u'db_row_pkey'))
op.add_column(
u'callset',
sa.Column('individual_id', sa.BIGINT(), autoincrement=False, nullable=False))
op.add_column(u'callset', sa.Column('dbrow_id', sa.BIGINT(), autoincrement=False, nullable=False))
op.drop_constraint('callset_source_sample_id_fkey','callset', type_='foreignkey')
op.drop_constraint('callset_target_sample_id_fkey','callset', type_='foreignkey')
op.create_foreign_key(u'callset_individual_id_fkey','callset', 'individual', ['individual_id'], ['id'])
op.create_foreign_key(u'callset_dbrow_id_fkey','callset', 'db_row', ['dbrow_id'], ['id'])
op.drop_column(u'callset', 'target_sample_id')
op.drop_column(u'callset', 'source_sample_id')
op.drop_index('db_array_id_tile_row_id_idx',table_name='callset_to_db_array_association')
op.drop_table('callset_to_db_array_association')
op.drop_table('sample')
5446559aecf7_txnreconcile_txn_id_not_null.py 文件源码
项目:biweeklybudget
作者: jantman
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def upgrade():
# When making changes to a column that has a foreign key, we need to drop
# and then re-add the constraint
op.execute('DELETE FROM txn_reconciles WHERE txn_id IS NULL;')
op.execute('LOCK TABLES txn_reconciles WRITE, transactions WRITE;')
op.drop_constraint('fk_txn_reconciles_txn_id_transactions',
'txn_reconciles', type_='foreignkey')
op.alter_column(
'txn_reconciles',
'txn_id',
existing_type=mysql.INTEGER(display_width=11),
nullable=False
)
op.create_foreign_key('fk_txn_reconciles_txn_id_transactions',
'txn_reconciles', 'transactions', ['txn_id'], ['id'])
op.execute('UNLOCK TABLES;')
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('comments', sa.Column('goodsID', sa.Integer(), nullable=True))
op.alter_column('comments', 'commentatorID',
existing_type=mysql.INTEGER(display_width=11),
nullable=True)
op.drop_constraint('comments_ibfk_2', 'comments', type_='foreignkey')
op.create_foreign_key(None, 'comments', 'goods', ['goodsID'], ['goodID'])
op.drop_column('comments', 'goodID')
op.add_column('goods', sa.Column('address', sa.String(length=128), nullable=False))
op.add_column('goods', sa.Column('poster', sa.String(length=128), nullable=False))
op.add_column('goods', sa.Column('times', sa.Integer(), nullable=True))
op.alter_column('orders', 'createDate',
existing_type=mysql.DATETIME(),
nullable=False)
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('orders', 'createDate',
existing_type=mysql.DATETIME(),
nullable=True)
op.drop_column('goods', 'times')
op.drop_column('goods', 'poster')
op.drop_column('goods', 'address')
op.add_column('comments', sa.Column('goodID', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False))
op.drop_constraint(None, 'comments', type_='foreignkey')
op.create_foreign_key('comments_ibfk_2', 'comments', 'goods', ['goodID'], ['goodID'])
op.alter_column('comments', 'commentatorID',
existing_type=mysql.INTEGER(display_width=11),
nullable=False)
op.drop_column('comments', 'goodsID')
### end Alembic commands ###
def change_inheriting_table(self, table_name, old_id_column_name, parent_table_name):
"""Tables of classes that inherit from other classes (using joint table inheritance) named their
primary key columns xxx_id (assuming the parent is called xxx here). These were also foreign
keys to the primary key of the parent table. In our Declarative implementation we just always use
the name `id` for a primary key regardless of the situation.
This method renames such primary key columns, and deal with the knock-on effect of this change
to related primary and foreign key as well.
:arg table_name: The name of the table underlying the child/inheriting class.
:arg old_id_column_name: The old name of the primary key column of the child/inheriting class.
:arg parent_table_name: The name of the table underlying the parent class.
"""
self.schedule('drop_fk', op.drop_constraint, '%s_%s_fkey' % (table_name, old_id_column_name), table_name)
self.rename_pk_column(table_name, old_id_column_name, 'id', ['id'])
self.schedule('create_fk', op.create_foreign_key, fk_name(table_name, 'id', parent_table_name), table_name,
parent_table_name, ['id'], ['id'], ondelete='CASCADE')
def rename_link_table(self):
old_table_name = 'requirement_deferred_actions__deferredaction_requirements'
new_table_name = 'deferredaction_requirement'
# Rename table itself
self.schedule('alter', op.rename_table, old_table_name, new_table_name)
# Rename of foreign key names
for old_name, other_table_name in [
('deferredaction_requirements_fk', 'deferredaction'),
('requirement_deferred_actions_fk', 'requirement') ]:
column_name = '%s_id' % other_table_name
new_name = fk_name(new_table_name, column_name, other_table_name)
self.schedule('drop_fk', op.drop_constraint, old_name, old_table_name)
self.schedule('create_fk', op.create_foreign_key, new_name, new_table_name, other_table_name, [column_name], ['id'])
# Primary keys are renamed according to new naming convention - in this case the table too
self.rename_pk(new_table_name, ['deferredaction_id', 'requirement_id'], old_table_name=old_table_name)
def change_task(self):
# Task in elixir did not generate a row_type for use as discriminator
self.schedule('alter', op.add_column, 'task', Column('row_type', String(40)))
# Task in elixir's queue_id was NULLABLE, but should not be (Tasks HAVE to be in a Queue now)
self.schedule('alter', op.alter_column, 'task', 'queue_id', nullable=True)
# Rename of relationship foreign key Task.reserved_by_id -> reserved_by_party_id
old_name = 'reserved_by_id'
new_name = 'reserved_by_party_id'
self.schedule('drop_fk', op.drop_constraint, '%s_%s_fk' % ('task', old_name), 'task')
self.schedule('alter', op.alter_column, 'task', old_name, new_column_name=new_name)
self.schedule('create_fk', op.create_foreign_key, fk_name('task', new_name, 'party'), 'task', 'party', [new_name], ['id'])
self.schedule('drop_pk', op.drop_index, ix_name('task', 'reserved_by_id'))
self.schedule('indexes', op.create_index, ix_name('task','reserved_by_party_id'), 'task', ['reserved_by_party_id'])
def upgrade():
conn = op.get_bind()
insp = inspect(conn)
fk_names = [fk['name'] for fk in insp.get_foreign_keys('host')]
if ("fk_hypervisor_id_resource_id" not in fk_names and
"fk_host_id_resource_id" in fk_names):
# NOTE(sileht): we are already good, the BD have been created from
# scratch after "a54c57ada3f5"
return
op.drop_constraint("fk_hypervisor_id_resource_id", "host",
type_="foreignkey")
op.drop_constraint("fk_hypervisor_history_resource_history_revision",
"host_history", type_="foreignkey")
op.create_foreign_key("fk_host_id_resource_id", "host", "resource",
["id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_host_history_resource_history_revision",
"host_history", "resource_history",
["revision"], ["revision"], ondelete="CASCADE")
a54c57ada3f5_removes_useless_indexes.py 文件源码
项目:gnocchi
作者: gnocchixyz
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def upgrade():
bind = op.get_bind()
# NOTE(sileht): mysql can't delete an index on a foreign key
# even this one is not the index used by the foreign key itself...
# In our case we have two indexes fk_resource_history_id_resource_id and
# and ix_resource_history_id, we want to delete only the second, but mysql
# can't do that with a simple DROP INDEX ix_resource_history_id...
# so we have to remove the constraint and put it back...
if bind.engine.name == "mysql":
op.drop_constraint("fk_resource_history_id_resource_id",
type_="foreignkey", table_name="resource_history")
for table, colname in resource_tables + history_tables + other_tables:
op.drop_index("ix_%s_%s" % (table, colname), table_name=table)
if bind.engine.name == "mysql":
op.create_foreign_key("fk_resource_history_id_resource_id",
"resource_history", "resource", ["id"], ["id"],
ondelete="CASCADE")
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('issue',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('topic_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('serial', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('published_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('title', sa.VARCHAR(length=128), server_default=sa.text(u"''::character varying"), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['topic_id'], [u'topic.id'], name=u'fk_issue_topic'),
sa.ForeignKeyConstraint(['user_id'], [u'user.id'], name=u'fk_issue_user'),
sa.PrimaryKeyConstraint('id', name=u'issue_pkey'),
sa.UniqueConstraint('topic_id', 'serial', name=u'ux_issue_topic_serial')
)
op.add_column('link', sa.Column('issue_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.drop_constraint('fk_link_topic', 'link', type_='foreignkey')
op.create_foreign_key(u'fk_link_issue', 'link', 'issue', ['issue_id'], ['id'])
op.create_index('ix_issue', 'link', ['issue_id'], unique=False)
op.drop_column('link', 'topic_id')
### end Alembic commands ###
fc7ea2a7e386_analytics_tables.py 文件源码
项目:fabric8-analytics-worker
作者: fabric8-analytics
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def upgrade():
"""Upgrade the database to a newer revision."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('stacks',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('is_ref_stack', sa.Boolean(), nullable=False),
sa.Column('stack_json', postgresql.JSONB(), nullable=False),
sa.PrimaryKeyConstraint('id'))
op.add_column('similar_stacks', sa.Column('analysis', postgresql.JSONB()))
op.add_column('similar_stacks', sa.Column('similar_stack_id', sa.Integer(), nullable=False))
op.add_column('similar_stacks', sa.Column('similarity_value', sa.Float(), nullable=False))
op.add_column('similar_stacks', sa.Column('stack_id', sa.Integer(), nullable=False))
op.create_unique_constraint('sim_unique', 'similar_stacks', ['stack_id', 'similar_stack_id'])
op.drop_constraint('similar_stacks_appstack_id_fkey', 'similar_stacks', type_='foreignkey')
op.create_foreign_key(None, 'similar_stacks', 'stacks', ['stack_id'], ['id'])
op.create_foreign_key(None, 'similar_stacks', 'stacks', ['similar_stack_id'], ['id'])
op.drop_column('similar_stacks', 'dependency_list')
op.drop_column('similar_stacks', 'appstack_id')
op.drop_table('reference_stacks')
op.drop_table('app_stacks')
# ### end Alembic commands ###
51415576d3e9_org_metadata.py 文件源码
项目:raw-data-repository
作者: all-of-us
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def downgrade_rdr():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(u'site', sa.Column('consortium_name', mysql.VARCHAR(length=255), nullable=False))
op.drop_constraint(None, 'site', type_='foreignkey')
op.alter_column(u'site', 'hpo_id',
existing_type=mysql.INTEGER(display_width=11),
nullable=False)
op.drop_column(u'site', 'zip_code')
op.drop_column(u'site', 'state')
op.drop_column(u'site', 'site_status')
op.drop_column(u'site', 'physical_location_name')
op.drop_column(u'site', 'phone_number')
op.drop_column(u'site', 'organization_id')
op.drop_column(u'site', 'notes')
op.drop_column(u'site', 'longitude')
op.drop_column(u'site', 'link')
op.drop_column(u'site', 'launch_date')
op.drop_column(u'site', 'latitude')
op.drop_column(u'site', 'directions')
op.drop_column(u'site', 'city')
op.drop_column(u'site', 'admin_emails')
op.drop_column(u'site', 'address_2')
op.drop_column(u'site', 'address_1')
op.drop_table('organization')
# ### end Alembic commands ###
172cd43879ac_ideacontentwidgetlink_are_positive_links.py 文件源码
项目:idealoom
作者: conversence
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def upgrade(pyramid_env):
with context.begin_transaction():
op.execute("""INSERT INTO idea_content_positive_link (id)
SELECT id FROM idea_content_widget_link""")
with context.begin_transaction():
try:
op.drop_constraint(
"idea_content_widget_link_idea_content_link_id_id",
"idea_content_widget_link")
except:
pass
with context.begin_transaction():
op.create_foreign_key(
"idea_content_widget_link_idea_content_positive_link_id_id",
"idea_content_widget_link", "idea_content_positive_link",
["id"], ["id"])
def downgrade(pyramid_env):
schema, user = config.get('db_schema'), config.get('db_user')
with context.begin_transaction():
for tablename in tables:
index_name = "%s_%s_%s_UNQC_base_id_tombstone_date" % (
schema, user, tablename)
op.drop_constraint(index_name, tablename, schema=schema)
op.add_column(tablename, sa.Column('is_tombstone', sa.SmallInteger, server_default="0"))
# repopulate is_tombstone
with transaction.manager:
for tablename in tables:
op.execute('UPDATE %s set "is_tombstone" = (CASE WHEN "tombstone_date" IS NULL THEN 0 ELSE 1 END)' % (tablename,))
mark_changed()
with context.begin_transaction():
for tablename in tables:
op.drop_column(tablename, "base_id")
op.drop_column(tablename, "tombstone_date")
op.drop_table(tablename+ID_TABLE)
op.execute('ALTER TABLE %s ADD CHECK ("is_tombstone" IN (0, 1))'%(tablename,))
d59114c46ac4_change_constrains.py 文件源码
项目:fuel-nailgun-extension-iac
作者: openstack
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def downgrade():
table_prefix = context.config.get_main_option('table_prefix')
op.drop_constraint('_repo_name_unique',
table_prefix + 'repos')
op.alter_column(table_prefix + 'repos',
'user_key',
existing_type=sa.UnicodeText(),
type_=sa.String(255))
3da51a88205a_ckan_api_key_constraint.py 文件源码
项目:FRG-Crowdsourcing
作者: 97amarnathk
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def downgrade():
op.drop_constraint('ckan_api_uq', 'user')
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('bit_appsflyer_connector', sa.Column('id', sa.Integer(), nullable=False))
op.drop_constraint(u'bit_appsflyer_connector_connector_id_fkey', 'bit_appsflyer_connector', type_='foreignkey')
op.create_foreign_key(None, 'bit_appsflyer_connector', 'bit_connectors', ['id'], ['id'])
op.drop_column('bit_appsflyer_connector', 'connector_id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('bit_appsflyer_connector', sa.Column('connector_id', sa.INTEGER(), autoincrement=False, nullable=False))
op.drop_constraint(None, 'bit_appsflyer_connector', type_='foreignkey')
op.create_foreign_key(u'bit_appsflyer_connector_connector_id_fkey', 'bit_appsflyer_connector', 'bit_connectors', ['connector_id'], ['id'])
op.drop_column('bit_appsflyer_connector', 'id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('bit_connectors_appsflyer', sa.Column('id', sa.INTEGER(), nullable=False))
op.drop_constraint(None, 'bit_connectors_appsflyer', type_='foreignkey')
op.drop_column('bit_connectors_appsflyer', 'connector_id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('bit_facebook_connector', sa.Column('connector_id', sa.INTEGER(), autoincrement=False, nullable=False))
op.drop_constraint(None, 'bit_facebook_connector', type_='foreignkey')
op.create_foreign_key(u'bit_facebook_connector_connector_id_fkey', 'bit_facebook_connector', 'bit_connectors', ['connector_id'], ['id'])
op.drop_column('bit_facebook_connector', 'id')
op.drop_constraint(None, 'bit_facebook_ad_account', type_='foreignkey')
op.create_foreign_key(u'bit_facebook_ad_account_connector_id_fkey', 'bit_facebook_ad_account', 'bit_facebook_connector', ['connector_id'], ['connector_id'])
op.drop_constraint(None, 'bit_adwords_google_drive_storage', type_='foreignkey')
op.create_foreign_key(u'bit_adwords_google_drive_storage_connector_id_fkey', 'bit_adwords_google_drive_storage', 'bit_adwords_connector', ['connector_id'], ['connector_id'])
op.add_column('bit_adwords_connector', sa.Column('connector_id', sa.INTEGER(), autoincrement=False, nullable=False))
op.drop_constraint(None, 'bit_adwords_connector', type_='foreignkey')
op.create_foreign_key(u'bit_adwords_connector_connector_id_fkey', 'bit_adwords_connector', 'bit_connectors', ['connector_id'], ['id'])
op.drop_column('bit_adwords_connector', 'id')
# ### end Alembic commands ###
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(u'bit_facebook_ad_campaigns_account_id_fkey', 'bit_facebook_ad_campaigns', type_='foreignkey')
op.drop_column('bit_facebook_ad_campaigns', 'account_id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'bit_adwords_google_drive_storage', type_='foreignkey')
op.drop_column('bit_adwords_google_drive_storage', 'connector_id')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'bit_facebook_ad_sets', type_='foreignkey')
op.create_index('ix_bit_facebook_ad_sets_campaign_id', 'bit_facebook_ad_sets', ['campaign_id'], unique=True)
op.create_index('ix_bit_facebook_ad_sets_account_id', 'bit_facebook_ad_sets', ['account_id'], unique=True)
op.drop_column(u'bit_facebook_ad_sets', 'ad_campaign_id')
op.drop_constraint(None, 'bit_facebook_ad_campaigns', type_='foreignkey')
op.create_index('ix_bit_facebook_ad_campaigns_account_id', 'bit_facebook_ad_campaigns', ['account_id'], unique=True)
op.drop_column(u'bit_facebook_ad_campaigns', 'ad_account_id')
op.drop_index(op.f('ix_bit_facebook_ad_native_id'), table_name='bit_facebook_ad')
op.drop_table('bit_facebook_ad')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'bit_chiter_connector', type_='foreignkey')
# ### end Alembic commands ###
17fd243e4dc4_make_description_not_nullable_and_unique.py 文件源码
项目:occrp-timeline-tool
作者: datamade
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'event', type_='unique')
op.alter_column('event', 'description',
existing_type=sa.VARCHAR(),
nullable=True)
# ### end Alembic commands ###