Python alembic.op.create_foreign_key() Examples

The following are 30 code examples of alembic.op.create_foreign_key(). 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: 3f51c0edfe02_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('targeting_survey',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('number_people_household', sa.Integer(), nullable=True),
    sa.Column('number_below_adult_age_household', sa.Integer(), nullable=True),
    sa.Column('number_people_women_household', sa.Integer(), nullable=True),
    sa.Column('number_people_men_household', sa.Integer(), nullable=True),
    sa.Column('number_people_work_household', sa.Integer(), nullable=True),
    sa.Column('disabilities_household', sa.String(), nullable=True),
    sa.Column('long_term_illnesses_household', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column('feedback', sa.Column('question', sa.String(), nullable=True))
    op.add_column('user', sa.Column('targeting_survey_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'user', 'targeting_survey', ['targeting_survey_id'], ['id'])
    # ### end Alembic commands ### 
Example #2
Source File: ed9c6ddc5c35_fix_host_foreign_key.py    From gnocchi with Apache License 2.0 6 votes vote down vote up
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") 
Example #3
Source File: a54c57ada3f5_removes_useless_indexes.py    From gnocchi with Apache License 2.0 6 votes vote down vote up
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") 
Example #4
Source File: 2b1743f77436_cascade_deleting_flags_when_tokens_are_.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def upgrade():
    """ Remove the existing foreign key in pull_request_flags.token_id and
    re-create it with CASCADE on delete and update.
    """
    # alter the constraints
    op.drop_constraint(
        'pull_request_flags_token_id_fkey', 'pull_request_flags',
        type_='foreignkey')
    op.create_foreign_key(
        u'pull_request_flags_token_id_fkey',
        'pull_request_flags',
        'tokens',
        ['token_id'],
        ['id'],
        ondelete="CASCADE",
        onupdate="CASCADE",
    ) 
Example #5
Source File: 2020_031416_11a35b448f83_.py    From app with MIT License 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('refused_email',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
    sa.Column('full_report_path', sa.String(length=128), nullable=False),
    sa.Column('path', sa.String(length=128), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('delete_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('full_report_path'),
    sa.UniqueConstraint('path')
    )
    op.add_column('forward_email_log', sa.Column('refused_email_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'forward_email_log', 'refused_email', ['refused_email_id'], ['id'], ondelete='SET NULL')
    # ### end Alembic commands ### 
Example #6
Source File: 2020_021023_6664d75ce3d4_.py    From app with MIT License 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('mailbox',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=256), nullable=False),
    sa.Column('verified', sa.Boolean(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.add_column('gen_email', sa.Column('mailbox_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'gen_email', 'mailbox', ['mailbox_id'], ['id'], ondelete='cascade')
    # ### end Alembic commands ### 
Example #7
Source File: 854bd902b1bc_change_kernel_identification.py    From backend.ai-manager with GNU Lesser General Public License v3.0 6 votes vote down vote up
def upgrade():
    op.drop_constraint('fk_vfolder_attachment_vfolder_vfolders', 'vfolder_attachment', type_='foreignkey')
    op.drop_constraint('fk_vfolder_attachment_kernel_kernels', 'vfolder_attachment', type_='foreignkey')
    op.drop_constraint('pk_kernels', 'kernels', type_='primary')
    op.add_column('kernels',
                  sa.Column('id', GUID(),
                            server_default=sa.text('uuid_generate_v4()'),
                            nullable=False))
    op.add_column('kernels', sa.Column('role', sa.String(length=16), nullable=False, default='master'))
    op.create_primary_key('pk_kernels', 'kernels', ['id'])
    op.alter_column(
        'kernels', 'sess_id',
        existing_type=postgresql.UUID(),
        type_=sa.String(length=64),
        nullable=True,
        existing_server_default=sa.text('uuid_generate_v4()'))
    op.create_index(op.f('ix_kernels_sess_id'), 'kernels', ['sess_id'], unique=False)
    op.create_index(op.f('ix_kernels_sess_id_role'), 'kernels', ['sess_id', 'role'], unique=False)
    op.create_foreign_key('fk_vfolder_attachment_vfolder_vfolders',
                          'vfolder_attachment', 'vfolders',
                          ['vfolder'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
    op.create_foreign_key('fk_vfolder_attachment_kernel_kernels',
                          'vfolder_attachment', 'kernels',
                          ['kernel'], ['id'], onupdate='CASCADE', ondelete='CASCADE') 
Example #8
Source File: 61ac23e35f86_fix_pr_project_from_key.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def upgrade():
    """ Alter the pull_requests table to update the foreign key to set null
    on delete.
    """

    op.drop_constraint(
        'pull_requests_project_id_from_fkey',
        'pull_requests',
        type_='foreignkey')
    op.create_foreign_key(
        name='pull_requests_project_id_from_fkey',
        source_table='pull_requests',
        referent_table='projects',
        local_cols=['project_id_from'],
        remote_cols=['id'],
        onupdate='cascade',
        ondelete='set null',
    ) 
Example #9
Source File: 61ac23e35f86_fix_pr_project_from_key.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def downgrade():
    """ Alter the pull_requests table to update the foreign key to cascade
    on delete.
    """

    op.drop_constraint(
        'pull_requests_project_id_from_fkey',
        'pull_requests',
        type_='foreignkey')
    op.create_foreign_key(
        name='pull_requests_project_id_from_fkey',
        source_table='pull_requests',
        referent_table='projects',
        local_cols=['project_id_from'],
        remote_cols=['id'],
        onupdate='cascade',
        ondelete='cascade',
    ) 
Example #10
Source File: 00027_c92e0c8632d7_more_rss_stuff.py    From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('rss_parser_feed_name_lut', sa.Column('feed_id', sa.BigInteger(), nullable=False))
    op.create_index(op.f('ix_rss_parser_feed_name_lut_feed_id'), 'rss_parser_feed_name_lut', ['feed_id'], unique=False)
    op.drop_index('ix_rss_parser_feed_name_lut_feed_name', table_name='rss_parser_feed_name_lut')
    op.drop_constraint('rss_parser_feed_name_lut_feed_netloc_feed_name_key', 'rss_parser_feed_name_lut', type_='unique')
    op.create_unique_constraint(None, 'rss_parser_feed_name_lut', ['feed_netloc', 'feed_id'])
    op.drop_constraint('rss_parser_feed_name_lut_feed_name_fkey', 'rss_parser_feed_name_lut', type_='foreignkey')
    op.create_foreign_key(None, 'rss_parser_feed_name_lut', 'rss_parser_funcs', ['feed_id'], ['id'])
    op.drop_column('rss_parser_feed_name_lut', 'feed_name')
    op.add_column('rss_parser_feed_name_lut_version', sa.Column('feed_id', sa.BigInteger(), autoincrement=False, nullable=True))
    op.create_index(op.f('ix_rss_parser_feed_name_lut_version_feed_id'), 'rss_parser_feed_name_lut_version', ['feed_id'], unique=False)
    op.drop_index('ix_rss_parser_feed_name_lut_version_feed_name', table_name='rss_parser_feed_name_lut_version')
    op.drop_column('rss_parser_feed_name_lut_version', 'feed_name')
    op.alter_column('rss_parser_funcs', 'func',
               existing_type=sa.TEXT(),
               nullable=True)
    ### end Alembic commands ### 
Example #11
Source File: 00027_c92e0c8632d7_more_rss_stuff.py    From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('rss_parser_funcs', 'func',
               existing_type=sa.TEXT(),
               nullable=False)
    op.add_column('rss_parser_feed_name_lut_version', sa.Column('feed_name', sa.TEXT(), autoincrement=False, nullable=True))
    op.create_index('ix_rss_parser_feed_name_lut_version_feed_name', 'rss_parser_feed_name_lut_version', ['feed_name'], unique=False)
    op.drop_index(op.f('ix_rss_parser_feed_name_lut_version_feed_id'), table_name='rss_parser_feed_name_lut_version')
    op.drop_column('rss_parser_feed_name_lut_version', 'feed_id')
    op.add_column('rss_parser_feed_name_lut', sa.Column('feed_name', sa.TEXT(), autoincrement=False, nullable=False))
    op.drop_constraint(None, 'rss_parser_feed_name_lut', type_='foreignkey')
    op.create_foreign_key('rss_parser_feed_name_lut_feed_name_fkey', 'rss_parser_feed_name_lut', 'rss_parser_funcs', ['feed_name'], ['feed_name'])
    op.drop_constraint(None, 'rss_parser_feed_name_lut', type_='unique')
    op.create_unique_constraint('rss_parser_feed_name_lut_feed_netloc_feed_name_key', 'rss_parser_feed_name_lut', ['feed_netloc', 'feed_name'])
    op.create_index('ix_rss_parser_feed_name_lut_feed_name', 'rss_parser_feed_name_lut', ['feed_name'], unique=False)
    op.drop_index(op.f('ix_rss_parser_feed_name_lut_feed_id'), table_name='rss_parser_feed_name_lut')
    op.drop_column('rss_parser_feed_name_lut', 'feed_id')
    ### end Alembic commands ### 
Example #12
Source File: 24f943b464ae_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('bank_account', sa.Column('kyc_application_id', sa.Integer(), nullable=True))
    op.add_column('bank_account', sa.Column('wyre_id', sa.String(), nullable=True))
    op.drop_constraint('bank_account_business_verification_id_fkey', 'bank_account', type_='foreignkey')
    op.create_foreign_key(None, 'bank_account', 'kyc_application', ['kyc_application_id'], ['id'])
    op.drop_column('bank_account', 'business_verification_id')
    op.drop_column('blockchain_transaction', 'has_output_txn')
    op.drop_column('blockchain_transaction', 'is_bitcoin')
    op.drop_column('credit_transfer', 'uuid')
    op.add_column('kyc_application', sa.Column('type', sa.String(), nullable=True))
    op.drop_constraint('transfer_card_user_id_fkey', 'transfer_card', type_='foreignkey')
    op.drop_column('transfer_card', '_amount_loaded')
    op.drop_column('transfer_card', 'user_id')
    op.drop_column('transfer_card', 'amount_loaded_signature')
    op.add_column('uploaded_document', sa.Column('kyc_application_id', sa.Integer(), nullable=True))
    op.drop_constraint('uploaded_document_business_verification_id_fkey', 'uploaded_document', type_='foreignkey')
    op.create_foreign_key(None, 'uploaded_document', 'kyc_application', ['kyc_application_id'], ['id'])
    op.drop_column('uploaded_document', 'business_verification_id')
    op.add_column('user', sa.Column('public_serial_number', sa.String(), nullable=True))
    op.drop_column('user', '_public_serial_number')
    # ### end Alembic commands ### 
Example #13
Source File: 24f943b464ae_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('_public_serial_number', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.drop_column('user', 'public_serial_number')
    op.add_column('uploaded_document', sa.Column('business_verification_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'uploaded_document', type_='foreignkey')
    op.create_foreign_key('uploaded_document_business_verification_id_fkey', 'uploaded_document', 'kyc_application', ['business_verification_id'], ['id'])
    op.drop_column('uploaded_document', 'kyc_application_id')
    op.add_column('transfer_card', sa.Column('amount_loaded_signature', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.add_column('transfer_card', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('transfer_card', sa.Column('_amount_loaded', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('transfer_card_user_id_fkey', 'transfer_card', 'user', ['user_id'], ['id'])
    op.drop_column('kyc_application', 'type')
    op.add_column('credit_transfer', sa.Column('uuid', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.add_column('blockchain_transaction', sa.Column('is_bitcoin', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('blockchain_transaction', sa.Column('has_output_txn', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('bank_account', sa.Column('business_verification_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'bank_account', type_='foreignkey')
    op.create_foreign_key('bank_account_business_verification_id_fkey', 'bank_account', 'kyc_application', ['business_verification_id'], ['id'])
    op.drop_column('bank_account', 'wyre_id')
    op.drop_column('bank_account', 'kyc_application_id')
    # ### end Alembic commands ### 
Example #14
Source File: c1bae50735e8_.py    From SempoBlockchain with GNU General Public License v3.0 6 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('user', 'last_name')
    op.drop_column('user', 'first_name')
    op.add_column('transfer_account', sa.Column('vendor_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('transfer_account', sa.Column('first_name', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.add_column('transfer_account', sa.Column('last_name', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.create_foreign_key('transfer_account_vendor_id_fkey', 'transfer_account', 'transfer_account', ['vendor_id'], ['id'])
    op.drop_column('transfer_account', 'payable_period_type')
    op.drop_column('transfer_account', 'payable_period_length')
    op.drop_column('transfer_account', 'payable_epoch')
    op.drop_column('transfer_account', 'name')
    op.drop_column('transfer_account', 'is_vendor')
    op.create_table('vendor',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('payable_period_type', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('payable_period_length', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='vendor_pkey')
    )
    # ### end Alembic commands ### 
Example #15
Source File: 34c517bcc2dd_shorter_foreign_key.py    From gnocchi with Apache License 2.0 5 votes vote down vote up
def upgrade():
    connection = op.get_bind()

    insp = sqlalchemy.inspect(connection)

    op.alter_column("resource_type", "tablename",
                    type_=sqlalchemy.String(35),
                    existing_type=sqlalchemy.String(18), nullable=False)

    for rt in connection.execute(resource_type_helper.select()):
        if rt.tablename == "generic":
            continue

        fk_names = [fk['name'] for fk in insp.get_foreign_keys("%s_history" %
                                                               rt.tablename)]
        fk_old = ("fk_%s_history_resource_history_revision" %
                  rt.tablename)
        if fk_old not in fk_names:
            # The table have been created from scratch recently
            fk_old = ("fk_%s_history_revision_resource_history_revision" %
                      rt.tablename)

        fk_new = "fk_%s_h_revision_rh_revision" % rt.tablename
        to_rename.append((fk_old, fk_new, 'resource_history', 'revision',
                          "%s_history" % rt.tablename, 'revision', 'CASCADE'))

    for (fk_old, fk_new, src_table, src_col, dst_table, dst_col, ondelete
         ) in to_rename:
        op.drop_constraint(fk_old, dst_table, type_="foreignkey")
        op.create_foreign_key(fk_new, dst_table, src_table,
                              [dst_col], [src_col], ondelete=ondelete) 
Example #16
Source File: 74c172d7b711_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('organisation', sa.Column('token_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'organisation', 'token', ['token_id'], ['id'])
    # ### end Alembic commands ### 
Example #17
Source File: c392929a91cc_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('email_whitelist', sa.Column('organisation_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'email_whitelist', 'organisation', ['organisation_id'], ['id'])
    # ### end Alembic commands ### 
Example #18
Source File: 20f02b5081bf_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('blockchain_address', sa.Column('type', sa.String(), nullable=True))
    op.add_column('blockchain_transaction', sa.Column('message', sa.String(), nullable=True))
    op.add_column('blockchain_transaction', sa.Column('signing_blockchain_address_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'blockchain_transaction', 'blockchain_address', ['signing_blockchain_address_id'], ['id'])
    # ### end Alembic commands ### 
Example #19
Source File: 9c4a43f3a227_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('blockchain_transaction', sa.Column('has_output_txn', sa.Boolean(), nullable=True))
    op.add_column('blockchain_transaction', sa.Column('is_bitcoin', sa.Boolean(), nullable=True))
    op.add_column('credit_transfer', sa.Column('uuid', sa.String(), nullable=True))
    op.add_column('transfer_card', sa.Column('_amount_loaded', sa.Integer(), nullable=True))
    op.add_column('transfer_card', sa.Column('amount_loaded_signature', sa.String(), nullable=True))
    op.add_column('transfer_card', sa.Column('user_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'transfer_card', 'user', ['user_id'], ['id'])
    op.add_column('user', sa.Column('_public_serial_number', sa.String(), nullable=True))
    op.drop_column('user', 'public_serial_number')
    # ### end Alembic commands ### 
Example #20
Source File: 77be7170b82d_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('user', 'kyc_state')
    op.drop_column('user', 'ap_user_id')
    op.drop_column('user', 'ap_paypal_id')
    op.drop_column('user', 'ap_bank_id')
    op.add_column('feedback', sa.Column('transfer_account_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'feedback', type_='foreignkey')
    op.create_foreign_key('feedback_transfer_account_id_fkey', 'feedback', 'transfer_account', ['transfer_account_id'], ['id'])
    op.drop_column('feedback', 'user_id')
    # ### end Alembic commands ### 
Example #21
Source File: 77be7170b82d_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('feedback', sa.Column('user_id', sa.Integer(), nullable=True))
    op.drop_constraint('feedback_transfer_account_id_fkey', 'feedback', type_='foreignkey')
    op.create_foreign_key(None, 'feedback', 'user', ['user_id'], ['id'])
    op.drop_column('feedback', 'transfer_account_id')
    op.add_column('user', sa.Column('ap_bank_id', sa.String(), nullable=True))
    op.add_column('user', sa.Column('ap_paypal_id', sa.String(), nullable=True))
    op.add_column('user', sa.Column('ap_user_id', sa.String(), nullable=True))
    op.add_column('user', sa.Column('kyc_state', sa.String(), nullable=True))
    # ### end Alembic commands ### 
Example #22
Source File: 9fce58914903_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('kyc_application', sa.Column('organisation_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'kyc_application', 'organisation', ['organisation_id'], ['id'])
    # ### end Alembic commands ### 
Example #23
Source File: d5ac8e623850_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('credit_transfer', sa.Column('token_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'credit_transfer', 'token', ['token_id'], ['id'])
    op.add_column('transfer_account', sa.Column('token_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'transfer_account', 'token', ['token_id'], ['id'])
    # ### end Alembic commands ### 
Example #24
Source File: 9ace61e2ea79_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_foreign_key('user_business_usage_id_fkey', 'user', 'transfer_usage', ['business_usage_id'], ['id'])
    # ### end Alembic commands ### 
Example #25
Source File: 925bbebe94bd_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('credit_transfer', sa.Column('recipient_user_id', sa.Integer(), nullable=True))
    op.add_column('credit_transfer', sa.Column('sender_user_id', sa.Integer(), nullable=True))
    op.alter_column('credit_transfer', 'sender_id', new_column_name='sender_transfer_account_id')
    op.alter_column('credit_transfer', 'recipient_id', new_column_name='recipient_transfer_account_id')
    op.create_foreign_key(None, 'credit_transfer', 'user', ['recipient_user_id'], ['id'])
    op.create_foreign_key(None, 'credit_transfer', 'user', ['sender_user_id'], ['id'])
    # ### end Alembic commands ### 
Example #26
Source File: 9c233f12de2c_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('transfer_account', sa.Column('owning_organisation_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('transfer_account_owning_organisation_id_fkey', 'transfer_account', 'organisation', ['owning_organisation_id'], ['id'])
    op.drop_constraint("fk_org_level_account", 'organisation', type_='foreignkey')
    op.drop_column('organisation', 'org_level_transfer_account_id')
    # ### end Alembic commands ### 
Example #27
Source File: 9c233f12de2c_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('organisation', sa.Column('org_level_transfer_account_id', sa.Integer(), nullable=True))
    op.create_foreign_key("fk_org_level_account", 'organisation', 'transfer_account', ['org_level_transfer_account_id'], ['id'])
    op.drop_constraint('transfer_account_owning_organisation_id_fkey', 'transfer_account', type_='foreignkey')
    op.drop_column('transfer_account', 'owning_organisation_id')
    # ### end Alembic commands ### 
Example #28
Source File: 1a852ec3bc90_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('default_transfer_account_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'user', 'transfer_account', ['default_transfer_account_id'], ['id'])
    # ### end Alembic commands ### 
Example #29
Source File: 3b2efd6da478_.py    From gitlab-tools with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('task_result', sa.Column('parent_id', sa.Integer(), nullable=True))
    op.create_index(op.f('ix_task_result_parent_id'), 'task_result', ['parent_id'], unique=False)
    op.create_foreign_key(None, 'task_result', 'task_result', ['parent_id'], ['id'])
    # ### end Alembic commands ### 
Example #30
Source File: 7583891c4ae5_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('chatbot_state',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('source_preference', sa.String(), nullable=True),
    sa.Column('transfer_initialised', sa.Boolean(), nullable=True),
    sa.Column('target_account_id', sa.Integer(), nullable=True),
    sa.Column('transfer_amount', sa.Integer(), nullable=True),
    sa.Column('prev_pin_failures', sa.Integer(), nullable=True),
    sa.Column('last_accessed', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('public_serial_number',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('public_serial_number', sa.String(), nullable=True),
    sa.Column('PIN', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('pin_to_public_id')
    op.add_column('user', sa.Column('_is_admin', sa.Boolean(), nullable=True))
    op.add_column('user', sa.Column('_is_subadmin', sa.Boolean(), nullable=True))
    op.add_column('user', sa.Column('_is_superadmin', sa.Boolean(), nullable=True))
    op.add_column('user', sa.Column('chatbot_state_id', sa.Integer(), nullable=True))
    op.add_column('user', sa.Column('nfc_serial_number', sa.String(), nullable=True))
    op.add_column('user', sa.Column('public_serial_number', sa.String(), nullable=True))
    op.add_column('user', sa.Column('secret', sa.String(), nullable=True))
    op.create_foreign_key(None, 'user', 'chatbot_state', ['chatbot_state_id'], ['id'])
    op.drop_column('user', 'is_admin')
    op.drop_column('user', 'is_superadmin')
    # ### end Alembic commands ###