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类create_foreign_key()的实例源码
2e00e70316c0_link_container_and_pod_states.py 文件源码
项目:kuberdock-platform
作者: cloudlinux
项目源码
文件源码
阅读 29
收藏 0
点赞 0
评论 0
2e00e70316c0_link_container_and_pod_states.py 文件源码
项目:kuberdock-platform
作者: cloudlinux
项目源码
文件源码
阅读 24
收藏 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')))
183533b82112_fix_callset_dbarray_mapping_individual_.py 文件源码
项目:GenomicsSampleAPIs
作者: Intel-HLS
项目源码
文件源码
阅读 24
收藏 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')
def create_foreign_key(
self, name, referent, local_cols, remote_cols, **kw):
"""Issue a "create foreign key" instruction using the
current batch migration context.
The batch form of this call omits the ``source`` and ``source_schema``
arguments from the call.
e.g.::
with batch_alter_table("address") as batch_op:
batch_op.create_foreign_key(
"fk_user_address",
"user", ["user_id"], ["id"])
.. seealso::
:meth:`.Operations.create_foreign_key`
"""
return super(BatchOperations, self).create_foreign_key(
name, self.impl.table_name, referent, local_cols, remote_cols,
source_schema=self.impl.schema, **kw)
5446559aecf7_txnreconcile_txn_id_not_null.py 文件源码
项目:biweeklybudget
作者: jantman
项目源码
文件源码
阅读 20
收藏 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 upgrade():
# we dont retain historical data as we simply dont care yet
op.execute('truncate table filecoverage')
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('filecoverage', sa.Column(
'build_id', zeus.db.types.guid.GUID(), nullable=False))
op.create_index(op.f('ix_filecoverage_build_id'),
'filecoverage', ['build_id'], unique=False)
op.create_unique_constraint('unq_coverage_filname', 'filecoverage', [
'build_id', 'filename'])
op.drop_constraint('unq_job_filname', 'filecoverage', type_='unique')
op.drop_constraint('filecoverage_job_id_fkey',
'filecoverage', type_='foreignkey')
op.create_foreign_key(None, 'filecoverage', 'build', [
'build_id'], ['id'], ondelete='CASCADE')
op.drop_column('filecoverage', 'job_id')
# ### 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)
3a37e844b277_alter_constraints.py 文件源码
项目:cci-demo-flask
作者: circleci
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'last_name')
op.drop_column('users', 'first_name')
### end Alembic commands ###
with op.batch_alter_table("notes") as batch_op:
batch_op.drop_constraint(
"notes_author_id_fkey", type_="foreignkey")
with op.batch_alter_table("notebooks") as batch_op:
batch_op.drop_constraint(
"notebooks_author_id_fkey", type_="foreignkey")
op.create_foreign_key(
"notes_author_id_fkey", "notes", "users",
["author_id"], ["id"], ondelete="CASCADE")
op.create_foreign_key(
"notebooks_author_id_fkey", "notebooks", "users",
["author_id"], ["id"], ondelete="CASCADE")
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
项目源码
文件源码
阅读 24
收藏 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
项目源码
文件源码
阅读 24
收藏 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 ###
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('licenses',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('plain_text', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('users_licenses',
sa.Column('user', sa.BigInteger(), nullable=True),
sa.Column('license', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['license'], ['licenses.id'], ),
sa.ForeignKeyConstraint(['user'], ['users.id'], )
)
op.drop_index('idx_areas_of_interest_centroid', table_name='areas_of_interest')
op.drop_index('idx_areas_of_interest_geometry', table_name='areas_of_interest')
op.add_column('projects', sa.Column('license_id', sa.Integer(), nullable=True))
op.create_foreign_key('fk_licenses', 'projects', 'licenses', ['license_id'], ['id'])
op.drop_index('idx_tasks_geometry', table_name='tasks')
# ### end Alembic commands ###
# Custom index, not created with reflection
op.create_index('idx_username_lower', 'users', [text('lower(username)')])
2fe1ed8ce31c_add_voting_type.py 文件源码
项目:vilfredo-core
作者: fairdemocracy
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
voting_types = op.create_table('voting_types',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=25), nullable=False),
sa.PrimaryKeyConstraint('id')
)
### Populate with question types
op.bulk_insert(voting_types,
[
{'name':'triangle'},
{'name':'linear'}
]
)
op.add_column(u'question', sa.Column('voting_type_id', sa.Integer(), nullable=False, server_default="1"))
op.create_foreign_key('fk_quesion_voting_types', 'question', 'voting_types', ['voting_type_id'], ['id'])
### end Alembic commands ###
26ef95fc6f2c_add_question_type.py 文件源码
项目:vilfredo-core
作者: fairdemocracy
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
question_types = op.create_table('question_types',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=25), nullable=False),
sa.PrimaryKeyConstraint('id')
)
### Populate with question types
op.bulk_insert(question_types,
[
{'name':'standard'},
{'name':'image'}
]
)
op.add_column(u'question', sa.Column('question_type_id', sa.Integer(), nullable=False, server_default="1"))
op.create_foreign_key('fk_quesion_question_types', 'question', 'question_types', ['question_type_id'], ['id'])
### end Alembic commands ###
452aa75feb90_added_notes_table_and_user_grading_.py 文件源码
项目:research-eGrader
作者: openstax
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('user_exercise_notes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('exercise_id', sa.Integer(), nullable=True),
sa.Column('text', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['exercise_id'], ['exercises.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user_grading_sessions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('started_on', sa.DateTime(), nullable=True),
sa.Column('ended_on', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.add_column(u'response_grade', sa.Column('session_id', sa.Integer(), nullable=True))
op.add_column(u'response_grade', sa.Column('submitted_on', sa.DateTime(), nullable=True))
op.create_foreign_key('response_grade_session_id_fkey', 'response_grade', 'user_grading_sessions', ['session_id'], ['id'])
### end Alembic commands ###
72c21b8fa484_add_nationality_ethnicity_to_patient.py 文件源码
项目:radar
作者: renalreg
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('patient_demographics', sa.Column('ethnicity_id', sa.Integer(), nullable=True))
op.add_column('patient_demographics', sa.Column('nationality_id', sa.Integer(), nullable=True))
op.execute('update patient_demographics set ethnicity_id = (select id from ethnicities where code = ethnicity)')
op.create_foreign_key(
'patient_demographics_ethnicity_id_fkey',
'patient_demographics',
'ethnicities',
['ethnicity_id'],
['id']
)
op.create_foreign_key(
'patient_demographics_nationality_id_fkey',
'patient_demographics',
'nationalities',
['nationality_id'],
['id']
)
op.drop_column('patient_demographics', 'ethnicity')
# ### end Alembic commands ###
172cd43879ac_ideacontentwidgetlink_are_positive_links.py 文件源码
项目:idealoom
作者: conversence
项目源码
文件源码
阅读 20
收藏 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 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 upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('bit_connectors_appsflyer', sa.Column('connector_id', sa.Integer(), nullable=False))
op.create_foreign_key(None, 'bit_connectors_appsflyer', 'bit_connectors', ['connector_id'], ['id'])
op.drop_column('bit_connectors_appsflyer', '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 downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('bit_facebook_ad_campaigns', sa.Column('account_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.create_foreign_key(u'bit_facebook_ad_campaigns_account_id_fkey', 'bit_facebook_ad_campaigns', 'bit_facebook_ad_account', ['account_id'], ['id'])
# ### end Alembic commands ###
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('bit_adwords_google_drive_storage', sa.Column('connector_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'bit_adwords_google_drive_storage', 'bit_adwords_connector', ['connector_id'], ['connector_id'])
# ### end Alembic commands ###
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('bit_facebook_ad',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('ad_set_id', sa.Integer(), nullable=True),
sa.Column('native_id', sa.String(length=255), nullable=True),
sa.Column('account_id', sa.String(length=255), nullable=True),
sa.Column('campaign_id', sa.String(length=255), nullable=True),
sa.Column('adset_id', sa.String(length=255), nullable=True),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('bid_amount', sa.Integer(), nullable=True),
sa.Column('bid_info', sa.String(length=255), nullable=True),
sa.Column('bid_type', sa.String(length=255), nullable=True),
sa.Column('configured_status', sa.String(length=255), nullable=True),
sa.Column('effective_status', sa.String(length=255), nullable=True),
sa.Column('status', sa.String(length=255), nullable=True),
sa.Column('created_time', sa.DateTime(), nullable=True),
sa.Column('updated_time', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['ad_set_id'], ['bit_facebook_ad_sets.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_bit_facebook_ad_native_id'), 'bit_facebook_ad', ['native_id'], unique=True)
op.add_column(u'bit_facebook_ad_campaigns', sa.Column('ad_account_id', sa.Integer(), nullable=True))
op.drop_index('ix_bit_facebook_ad_campaigns_account_id', table_name='bit_facebook_ad_campaigns')
op.create_foreign_key(None, 'bit_facebook_ad_campaigns', 'bit_facebook_ad_account', ['ad_account_id'], ['id'])
op.add_column(u'bit_facebook_ad_sets', sa.Column('ad_campaign_id', sa.Integer(), nullable=True))
op.drop_index('ix_bit_facebook_ad_sets_account_id', table_name='bit_facebook_ad_sets')
op.drop_index('ix_bit_facebook_ad_sets_campaign_id', table_name='bit_facebook_ad_sets')
op.create_foreign_key(None, 'bit_facebook_ad_sets', 'bit_facebook_ad_campaigns', ['ad_campaign_id'], ['id'])
# ### end Alembic commands ###
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key(None, 'bit_chiter_connector', 'bit_connectors', ['id'], ['id'])
# ### end Alembic commands ###
5f6302b63190_remove_event_title_and_create_location_.py 文件源码
项目:occrp-timeline-tool
作者: datamade
项目源码
文件源码
阅读 27
收藏 0
点赞 0
评论 0
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('location',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('location', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('location')
)
op.add_column('event', sa.Column('location_id', sa.Integer(), nullable=True))
op.drop_constraint('event_title_key', 'event', type_='unique')
op.create_foreign_key(None, 'event', 'location', ['location_id'], ['id'])
op.drop_column('event', 'title')
# ### end Alembic commands ###