Python alembic.op.f() Examples
The following are 30
code examples of alembic.op.f().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
alembic.op
, or try the search function
.
Example #1
Source File: a90076b18837_tasks_and_shift.py From gamification-engine with MIT License | 6 votes |
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_column('achievements', 'evaluation_shift') op.drop_index(op.f('ix_taskexecutions_task_id'), table_name='taskexecutions') op.drop_index(op.f('ix_taskexecutions_success'), table_name='taskexecutions') op.drop_index(op.f('ix_taskexecutions_planned_at'), table_name='taskexecutions') op.drop_index(op.f('ix_taskexecutions_locked_at'), table_name='taskexecutions') op.drop_index(op.f('ix_taskexecutions_finished_at'), table_name='taskexecutions') op.drop_index(op.f('ix_taskexecutions_canceled_at'), table_name='taskexecutions') op.drop_table('taskexecutions') op.drop_index(op.f('ix_tasks_task_name'), table_name='tasks') op.drop_index(op.f('ix_tasks_is_manually_modified'), table_name='tasks') op.drop_index(op.f('ix_tasks_is_removed'), table_name='tasks') op.drop_index(op.f('ix_tasks_is_auto_created'), table_name='tasks') op.drop_index(op.f('ix_tasks_entry_name'), table_name='tasks') op.drop_table('tasks') ### end Alembic commands ###
Example #2
Source File: 1083bb6545c9_.py From website with MIT License | 6 votes |
def downgrade(): op.create_table( "project_members", sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=True), sa.Column("project_id", sa.INTEGER(), autoincrement=False, nullable=True), sa.Column( "date_joined", postgresql.TIMESTAMP(), autoincrement=False, nullable=True ), sa.Column("is_lead", sa.BOOLEAN(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint( ["project_id"], ["projects.id"], name="project_members_project_id_fkey" ), sa.ForeignKeyConstraint( ["user_id"], ["users.id"], name="project_members_user_id_fkey" ), ) op.drop_index( op.f("ix_project_memberships_is_lead"), table_name="project_memberships" ) op.drop_table("project_memberships")
Example #3
Source File: 1083bb6545c9_.py From website with MIT License | 6 votes |
def upgrade(): op.create_table( "project_memberships", sa.Column("id", sa.Integer(), nullable=False), sa.Column("user_id", sa.Integer(), nullable=True), sa.Column("project_id", sa.Integer(), nullable=True), sa.Column("date_joined", sa.DateTime(), nullable=True), sa.Column("is_lead", sa.Boolean(), nullable=False), sa.ForeignKeyConstraint(["project_id"], ["projects.id"]), sa.ForeignKeyConstraint(["user_id"], ["users.id"]), sa.PrimaryKeyConstraint("id"), ) op.create_index( op.f("ix_project_memberships_is_lead"), "project_memberships", ["is_lead"], unique=False, ) op.drop_table("project_members")
Example #4
Source File: 62a8d746d13b_5_0_to_5_0_5.py From cloudify-manager with Apache License 2.0 | 6 votes |
def _update_managers_table(): op.add_column('managers', sa.Column('node_id', sa.Text(), nullable=True)) op.add_column('managers', sa.Column('last_seen', UTCDateTime(), nullable=False, server_default=sa.func.current_timestamp())) op.add_column('managers', sa.Column('status_report_frequency', sa.Integer(), nullable=True)) op.execute(""" UPDATE managers SET node_id = hostname; """) op.alter_column('managers', 'node_id', nullable=False) op.create_unique_constraint(op.f('managers_node_id_key'), 'managers', ['node_id']) op.create_index(op.f('managers_last_seen_idx'), 'managers', ['last_seen'], unique=False)
Example #5
Source File: 0068_add_created_by_to_provider.py From notifications-api with MIT License | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('provider_details', sa.Column('created_by_id', postgresql.UUID(as_uuid=True), nullable=True)) op.create_index(op.f('ix_provider_details_created_by_id'), 'provider_details', ['created_by_id'], unique=False) op.create_foreign_key('provider_details_created_by_id_fkey', 'provider_details', 'users', ['created_by_id'], ['id']) op.add_column('provider_details_history', sa.Column('created_by_id', postgresql.UUID(as_uuid=True), nullable=True)) op.create_index( op.f('ix_provider_details_history_created_by_id'), 'provider_details_history', ['created_by_id'], unique=False ) op.create_foreign_key( 'provider_details_history_created_by_id_fkey', 'provider_details_history', 'users', ['created_by_id'], ['id'] ) # ### end Alembic commands ###
Example #6
Source File: d90948124e46_add_tables_for_triggers_koji_and_tests.py From packit-service with MIT License | 6 votes |
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column( "copr_builds", sa.Column("pr_id", sa.INTEGER(), autoincrement=False, nullable=True), ) op.drop_constraint(None, "copr_builds", type_="foreignkey") op.create_foreign_key( "copr_builds_pr_id_fkey1", "copr_builds", "pull_requests", ["pr_id"], ["id"] ) op.drop_column("copr_builds", "job_trigger_id") op.drop_index(op.f("ix_tft_test_runs_pipeline_id"), table_name="tft_test_runs") op.drop_table("tft_test_runs") op.drop_table("project_releases") op.drop_index(op.f("ix_project_issues_issue_id"), table_name="project_issues") op.drop_table("project_issues") op.drop_index(op.f("ix_koji_builds_build_id"), table_name="koji_builds") op.drop_table("koji_builds") op.drop_table("git_branches") op.drop_table("build_triggers") # ### end Alembic commands ###
Example #7
Source File: 20200705_16-09-04__add_slack_user_table.py From busy-beaver with MIT License | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "slack_user", sa.Column("id", sa.Integer(), nullable=False), sa.Column("date_created", sa.DateTime(), nullable=True), sa.Column("date_modified", sa.DateTime(), nullable=True), sa.Column("installation_id", sa.Integer(), nullable=False), sa.Column("slack_id", sa.String(length=30), nullable=False), sa.Column("slack_oauth_state", sa.String(length=36), nullable=True), sa.ForeignKeyConstraint( ["installation_id"], ["slack_installation.id"], name="fk_installation_id" ), sa.PrimaryKeyConstraint("id"), ) op.create_index( op.f("ix_slack_user_installation_id"), "slack_user", ["installation_id"], unique=False, ) op.create_index( op.f("ix_slack_user_slack_id"), "slack_user", ["slack_id"], unique=False ) # ### end Alembic commands ###
Example #8
Source File: 4292b00185bf_whitelist.py From packit-service with MIT License | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "whitelist", sa.Column("id", sa.Integer(), nullable=False), sa.Column("account_name", sa.String(), nullable=True), sa.Column( "status", sa.Enum( "approved_automatically", "waiting", "approved_manually", name="whiteliststatus", ), nullable=True, ), sa.PrimaryKeyConstraint("id"), ) op.create_index( op.f("ix_whitelist_account_name"), "whitelist", ["account_name"], unique=False ) # ### end Alembic commands ###
Example #9
Source File: 9a91532c8534_add_scaling_group.py From backend.ai-manager with GNU Lesser General Public License v3.0 | 6 votes |
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint(op.f('fk_kernels_scaling_group_scaling_groups'), 'kernels', type_='foreignkey') op.drop_index(op.f('ix_kernels_scaling_group'), table_name='kernels') op.drop_column('kernels', 'scaling_group') op.drop_constraint(op.f('fk_agents_scaling_group_scaling_groups'), 'agents', type_='foreignkey') op.drop_index(op.f('ix_agents_scaling_group'), table_name='agents') op.drop_column('agents', 'scaling_group') op.drop_index(op.f('ix_sgroups_for_keypairs_scaling_group'), table_name='sgroups_for_keypairs') op.drop_index(op.f('ix_sgroups_for_keypairs_access_key'), table_name='sgroups_for_keypairs') op.drop_table('sgroups_for_keypairs') op.drop_index(op.f('ix_sgroups_for_groups_scaling_group'), table_name='sgroups_for_groups') op.drop_index(op.f('ix_sgroups_for_groups_group'), table_name='sgroups_for_groups') op.drop_table('sgroups_for_groups') op.drop_index(op.f('ix_sgroups_for_domains_scaling_group'), table_name='sgroups_for_domains') op.drop_index(op.f('ix_sgroups_for_domains_domain'), table_name='sgroups_for_domains') op.drop_table('sgroups_for_domains') op.drop_index(op.f('ix_scaling_groups_is_active'), table_name='scaling_groups') op.drop_table('scaling_groups') # ### end Alembic commands ###
Example #10
Source File: test_op_naming_convention.py From alembic with MIT License | 6 votes |
def test_add_column_schema_type_w_f(self): context = op_fixture( naming_convention={"ck": "ck_%(table_name)s_%(constraint_name)s"} ) op.add_column( "t1", Column( "c1", Boolean(name=op.f("foo"), create_constraint=True), nullable=False, ), ) context.assert_( "ALTER TABLE t1 ADD COLUMN c1 BOOLEAN NOT NULL", "ALTER TABLE t1 ADD CONSTRAINT foo CHECK (c1 IN (0, 1))", )
Example #11
Source File: 71a34df585ed_migrate_coverage.py From zeus with Apache License 2.0 | 6 votes |
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 ###
Example #12
Source File: test_op_naming_convention.py From alembic with MIT License | 6 votes |
def test_add_check_constraint_inline_on_column_w_f(self): context = op_fixture( naming_convention={"ck": "ck_%(table_name)s_%(constraint_name)s"} ) op.create_table( "some_table", Column( "x", Integer, CheckConstraint("im a constraint", name=op.f("ck_q_cc1")), ), ) context.assert_( "CREATE TABLE some_table " "(x INTEGER CONSTRAINT ck_q_cc1 CHECK (im a constraint))" )
Example #13
Source File: 0072_add_dvla_orgs.py From notifications-api with MIT License | 5 votes |
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('dvla_organisation', sa.Column('id', sa.String(), nullable=False), sa.Column('name', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id') ) # insert initial values - HMG and Land Reg op.execute(""" INSERT INTO dvla_organisation VALUES ('001', 'HM Government'), ('500', 'Land Registry') """) op.add_column('services', sa.Column('dvla_organisation_id', sa.String(), nullable=True, server_default='001')) op.add_column('services_history', sa.Column('dvla_organisation_id', sa.String(), nullable=True, server_default='001')) # set everything to be HMG for now op.execute("UPDATE services SET dvla_organisation_id = '001'") op.execute("UPDATE services_history SET dvla_organisation_id = '001'") op.alter_column('services', 'dvla_organisation_id', nullable=False) op.alter_column('services_history', 'dvla_organisation_id', nullable=False) op.create_index( op.f('ix_services_dvla_organisation_id'), 'services', ['dvla_organisation_id'], unique=False ) op.create_index( op.f('ix_services_history_dvla_organisation_id'), 'services_history', ['dvla_organisation_id'], unique=False ) op.create_foreign_key(None, 'services', 'dvla_organisation', ['dvla_organisation_id'], ['id'])
Example #14
Source File: 2f1507bf6dc1_create_application_manifests_table.py From commandment with MIT License | 5 votes |
def schema_downgrades(): """schema downgrade migrations go here.""" # Commented items from an earlier migration: # op.drop_constraint(op.f('uq_application_manifest_checksum_manifest_index'), # table_name='application_manifest_checksums') # op.drop_table('application_manifest_checksums') # op.drop_index(op.f('ix_applications_manifests_bundle_version'), table_name='applications_manifests') # op.drop_index(op.f('ix_applications_manifests_bundle_id'), table_name='applications_manifests') # op.drop_table('applications_manifests') op.drop_table('application_manifest_checksums') op.drop_table('application_manifests')
Example #15
Source File: 9227d42a8935_failure_reasons.py From zeus with Apache License 2.0 | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "failurereason", sa.Column("job_id", zeus.db.types.guid.GUID(), nullable=False), sa.Column("reason", zeus.db.types.enum.StrEnum(), nullable=False), sa.Column("repository_id", zeus.db.types.guid.GUID(), nullable=False), sa.Column("id", zeus.db.types.guid.GUID(), nullable=False), sa.Column( "date_created", sa.TIMESTAMP(timezone=True), server_default=sa.text("now()"), nullable=False, ), sa.ForeignKeyConstraint(["job_id"], ["job.id"], ondelete="CASCADE"), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], ondelete="CASCADE" ), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("job_id", "reason", name="unq_failurereason_key"), ) op.create_index( op.f("ix_failurereason_repository_id"), "failurereason", ["repository_id"], unique=False, ) # ### end Alembic commands ###
Example #16
Source File: 89a8aa1c611c_add_webpack_stats.py From zeus with Apache License 2.0 | 5 votes |
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index( op.f("ix_webpack_entrypoint_repository_id"), table_name="webpack_entrypoint" ) op.drop_table("webpack_entrypoint") op.drop_index(op.f("ix_webpack_asset_repository_id"), table_name="webpack_asset") op.drop_table("webpack_asset") # ### end Alembic commands ###
Example #17
Source File: 20200125_02-16-15__create_slack_app_home_opened_counter.py From busy-beaver with MIT License | 5 votes |
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index( op.f("ix_slack_app_home_opened_slack_id"), table_name="slack_app_home_opened" ) op.drop_index( op.f("ix_slack_app_home_opened_installation_id"), table_name="slack_app_home_opened", ) op.drop_table("slack_app_home_opened") # ### end Alembic commands ###
Example #18
Source File: 20200125_02-16-15__create_slack_app_home_opened_counter.py From busy-beaver with MIT License | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "slack_app_home_opened", sa.Column("id", sa.Integer(), nullable=False), sa.Column("date_created", sa.DateTime(), nullable=True), sa.Column("date_modified", sa.DateTime(), nullable=True), sa.Column("installation_id", sa.Integer(), nullable=False), sa.Column("slack_id", sa.String(length=30), nullable=False), sa.Column("count", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["installation_id"], ["slack_installation.id"], name="fk_installation_id" ), sa.PrimaryKeyConstraint("id"), ) op.create_index( op.f("ix_slack_app_home_opened_installation_id"), "slack_app_home_opened", ["installation_id"], unique=False, ) op.create_index( op.f("ix_slack_app_home_opened_slack_id"), "slack_app_home_opened", ["slack_id"], unique=False, ) # ### end Alembic commands ###
Example #19
Source File: 20200705_16-09-04__add_slack_user_table.py From busy-beaver with MIT License | 5 votes |
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f("ix_slack_user_slack_id"), table_name="slack_user") op.drop_index(op.f("ix_slack_user_installation_id"), table_name="slack_user") op.drop_table("slack_user") # ### end Alembic commands ###
Example #20
Source File: d05e8a773f11_add_testcase_rollup.py From zeus with Apache License 2.0 | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "testcase_rollup", sa.Column("id", zeus.db.types.guid.GUID(), nullable=False), sa.Column("hash", sa.String(length=40), nullable=False), sa.Column("name", sa.Text(), nullable=False), sa.Column("date", sa.Date(), nullable=False), sa.Column("total_runs", sa.Integer(), nullable=False), sa.Column("total_duration", sa.Integer(), nullable=False), sa.Column("runs_failed", sa.Integer(), nullable=False), sa.Column("runs_passed", sa.Integer(), nullable=False), sa.Column("repository_id", zeus.db.types.guid.GUID(), nullable=False), sa.ForeignKeyConstraint( ["repository_id"], ["repository.id"], ondelete="CASCADE" ), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint( "repository_id", "hash", "date", name="unq_testcase_rollup_hash" ), ) op.create_index( op.f("ix_testcase_rollup_repository_id"), "testcase_rollup", ["repository_id"], unique=False, ) # ### end Alembic commands ###
Example #21
Source File: 62a8d746d13b_5_0_to_5_0_5.py From cloudify-manager with Apache License 2.0 | 5 votes |
def _update_brokers_table(): op.add_column('rabbitmq_brokers', sa.Column('is_external', sa.Boolean(), nullable=False, server_default='f')) op.add_column('rabbitmq_brokers', sa.Column('node_id', sa.Text(), nullable=True)) op.execute(""" UPDATE rabbitmq_brokers SET node_id = name; """) op.alter_column('rabbitmq_brokers', 'node_id', nullable=False) op.create_unique_constraint(op.f('rabbitmq_brokers_node_id_key'), 'rabbitmq_brokers', ['node_id'])
Example #22
Source File: test_mssql.py From alembic with MIT License | 5 votes |
def test_create_index_mssql_include_is_none(self): context = op_fixture("mssql") op.create_index( op.f("ix_mytable_a_b"), "mytable", ["col_a", "col_b"], unique=False ) context.assert_contains( "CREATE INDEX ix_mytable_a_b ON mytable " "(col_a, col_b)" )
Example #23
Source File: 0119_add_email_reply_to.py From notifications-api with MIT License | 5 votes |
def downgrade(): op.drop_index(op.f('ix_service_email_reply_to_service_id'), table_name='service_email_reply_to') op.drop_table('service_email_reply_to')
Example #24
Source File: 0119_add_email_reply_to.py From notifications-api with MIT License | 5 votes |
def upgrade(): op.create_table('service_email_reply_to', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('email_address', sa.Text(), nullable=False), sa.Column('is_default', sa.Boolean(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['service_id'], ['services.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index( op.f('ix_service_email_reply_to_service_id'), 'service_email_reply_to', ['service_id'], unique=False )
Example #25
Source File: 0068_add_created_by_to_provider.py From notifications-api with MIT License | 5 votes |
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint('provider_details_history_created_by_id_fkey', 'provider_details_history', type_='foreignkey') op.drop_index(op.f('ix_provider_details_history_created_by_id'), table_name='provider_details_history') op.drop_column('provider_details_history', 'created_by_id') op.drop_constraint('provider_details_created_by_id_fkey', 'provider_details', type_='foreignkey') op.drop_index(op.f('ix_provider_details_created_by_id'), table_name='provider_details') op.drop_column('provider_details', 'created_by_id') # ### end Alembic commands ###
Example #26
Source File: test_mssql.py From alembic with MIT License | 5 votes |
def test_create_index_mssql_include(self): context = op_fixture("mssql") op.create_index( op.f("ix_mytable_a_b"), "mytable", ["col_a", "col_b"], unique=False, mssql_include=["col_c"], ) context.assert_contains( "CREATE INDEX ix_mytable_a_b ON mytable " "(col_a, col_b) INCLUDE (col_c)" )
Example #27
Source File: d90948124e46_add_tables_for_triggers_koji_and_tests.py From packit-service with MIT License | 5 votes |
def __repr__(self): return f"COPRBuildUpgradeModel(id={self.id}, job_trigger={self.job_trigger})"
Example #28
Source File: d90948124e46_add_tables_for_triggers_koji_and_tests.py From packit-service with MIT License | 5 votes |
def __repr__(self): return f"PullRequestUpgradeModel(id={self.pr_id}, project={self.project})"
Example #29
Source File: d90948124e46_add_tables_for_triggers_koji_and_tests.py From packit-service with MIT License | 5 votes |
def __repr__(self): return f"GitProjectUpgradeModel(name={self.namespace}/{self.repo_name})"
Example #30
Source File: 4292b00185bf_whitelist.py From packit-service with MIT License | 5 votes |
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f("ix_whitelist_account_name"), table_name="whitelist") op.drop_table("whitelist") # ### end Alembic commands ###