Python sqlalchemy.INTEGER Examples

The following are 30 code examples of sqlalchemy.INTEGER(). 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 sqlalchemy , or try the search function .
Example #1
Source File: 7583891c4ae5_.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('is_superadmin', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('user', sa.Column('is_admin', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'user', type_='foreignkey')
    op.drop_column('user', 'secret')
    op.drop_column('user', 'public_serial_number')
    op.drop_column('user', 'nfc_serial_number')
    op.drop_column('user', 'chatbot_state_id')
    op.drop_column('user', '_is_superadmin')
    op.drop_column('user', '_is_subadmin')
    op.drop_column('user', '_is_admin')
    op.create_table('pin_to_public_id',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('public_id', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('PIN', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='pin_to_public_id_pkey')
    )
    op.drop_table('public_serial_number')
    op.drop_table('chatbot_state')
    # ### end Alembic commands ### 
Example #2
Source File: 900758871713_.py    From contentdb with GNU General Public License v3.0 6 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('softdeps',
        sa.Column('package_id', sa.INTEGER(), nullable=False),
        sa.Column('dependency_id', sa.INTEGER(), nullable=False),
        sa.ForeignKeyConstraint(['dependency_id'], ['package.id'], ),
        sa.ForeignKeyConstraint(['package_id'], ['package.id'], ),
        sa.PrimaryKeyConstraint('package_id', 'dependency_id')
    )
    op.create_table('harddeps',
        sa.Column('package_id', sa.INTEGER(), nullable=False),
        sa.Column('dependency_id', sa.INTEGER(), nullable=False),
        sa.ForeignKeyConstraint(['dependency_id'], ['package.id'], ),
        sa.ForeignKeyConstraint(['package_id'], ['package.id'], ),
        sa.PrimaryKeyConstraint('package_id', 'dependency_id')
    )
    op.drop_table('provides')
    op.drop_table('meta_package')
    # ### end Alembic commands ### 
Example #3
Source File: 19e8725e0581_.py    From gitlab-tools with GNU General Public License v3.0 6 votes vote down vote up
def downgrade():
    bind = op.get_bind()
    session = Session(bind=bind)
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('pull_mirror', sa.Column('gitlab_id', sa.INTEGER(), nullable=True))

    for pull_mirror in session.query(PullMirror):
        pull_mirror.gitlab_id = pull_mirror.project.gitlab_id
        session.add(pull_mirror)
    session.commit()

    op.drop_constraint(None, 'pull_mirror', type_='foreignkey')
    op.drop_index(op.f('ix_pull_mirror_project_id'), table_name='pull_mirror')
    op.drop_column('pull_mirror', 'project_id')
    op.drop_index(op.f('ix_push_mirror_user_id'), table_name='push_mirror')
    op.drop_index(op.f('ix_push_mirror_project_id'), table_name='push_mirror')
    op.drop_table('push_mirror')
    op.drop_table('project')
    # ### end Alembic commands ### 
Example #4
Source File: d90948124e46_add_tables_for_triggers_koji_and_tests.py    From packit-service with MIT License 6 votes vote down vote up
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 #5
Source File: 875c52a485_.py    From comport with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('months',
    sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('months_id_seq'::regclass)"), nullable=False),
    sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('department_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['department_id'], ['departments.id'], name='months_department_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='months_pkey'),
    postgresql_ignore_search_path=False
    )
    op.create_table('serviceTypes',
    sa.Column('id', sa.INTEGER(), server_default=sa.text('nextval(\'"serviceTypes_id_seq"\'::regclass)'), nullable=False),
    sa.Column('month_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('service_type', sa.VARCHAR(length=36), autoincrement=False, nullable=False),
    sa.Column('count', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['month_id'], ['months.id'], name='serviceTypes_month_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='serviceTypes_pkey')
    )
    op.drop_table('use_of_force_incidents')
    ### end Alembic commands ### 
Example #6
Source File: 131ad2dc5bbd_table_for_no_new_branches_hook.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def upgrade():
    """ Create table for PagureNoNewBranchesHook. """
    op.create_table(
        'hook_pagure_no_new_branches',
        sa.Column('id', sa.INTEGER(), nullable=False),
        sa.Column('project_id', sa.INTEGER(), nullable=False),
        sa.Column('active', sa.BOOLEAN(), nullable=False),
        sa.ForeignKeyConstraint(
            ['project_id'],
            [u'projects.id'],
            name=u'hook_pagure_no_new_branches_project_id_fkey',
            onupdate=u'CASCADE',
            ondelete=u'CASCADE'
        ),
        sa.PrimaryKeyConstraint('id', name=u'hook_pagure_no_new_branches_pkey')
    ) 
Example #7
Source File: 551c4e6d4a8b_.py    From app with MIT License 6 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('client_scope',
    sa.Column('client_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('scope_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['client_id'], ['client.id'], name='client_scope_client_id_fkey', ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['scope_id'], ['scope.id'], name='client_scope_scope_id_fkey', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('client_id', 'scope_id', name='client_scope_pkey')
    )
    op.create_table('scope',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('name', sa.VARCHAR(length=128), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id', name='scope_pkey'),
    sa.UniqueConstraint('name', name='scope_name_key')
    )
    # ### end Alembic commands ### 
Example #8
Source File: 2020_041911_dd911f880b75_.py    From app with MIT License 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('apple_subscription',
    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('expires_date', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.Column('original_transaction_id', sa.String(length=256), nullable=False),
    sa.Column('receipt_data', sa.Text(), nullable=False),
    sa.Column('plan', sa.Enum('monthly', 'yearly', name='planenum_apple'), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id')
    )
    op.alter_column('file', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    # ### end Alembic commands ### 
Example #9
Source File: compiler.py    From ibis with Apache License 2.0 6 votes vote down vote up
def postgresql_array_search(element, compiler, **kw):
    needle, haystack = element.clauses
    i = sa.func.generate_subscripts(haystack, 1).alias('i')
    c0 = sa.column('i', type_=sa.INTEGER(), _selectable=i)
    result = (
        sa.func.coalesce(
            sa.select([c0])
            .where(haystack[c0].op('IS NOT DISTINCT FROM')(needle))
            .order_by(c0)
            .limit(1)
            .as_scalar(),
            0,
        )
        - 1
    )
    string_result = compiler.process(result, **kw)
    return string_result 
Example #10
Source File: 1083bb6545c9_.py    From website with MIT License 6 votes vote down vote up
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 #11
Source File: ba9c2a8e7338_.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.create_table('referral',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('first_name', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('last_name', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('reason', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('_phone', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('referring_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['referring_user_id'], ['user.id'], name='referral_referring_user_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='referral_pkey')
    )
    # ### end Alembic commands ### 
Example #12
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 #13
Source File: 026e6bde589e_.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.create_table('blockchain_transaction',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('submitted_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('added_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('hash', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('credit_transfer_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('block', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('status', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('transaction_type', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('message', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('signing_blockchain_address_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('nonce', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('has_output_txn', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('is_bitcoin', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['credit_transfer_id'], ['credit_transfer.id'], name='blockchain_transaction_credit_transfer_id_fkey'),
    sa.ForeignKeyConstraint(['signing_blockchain_address_id'], ['blockchain_address.id'], name='blockchain_transaction_signing_blockchain_address_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='blockchain_transaction_pkey')
    )
    # ### end Alembic commands ### 
Example #14
Source File: c9db3658816a_.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('organisation', 'system_blockchain_address')
    op.create_table('spend_approvals',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('eth_send_task_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('approval_task_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('token_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('giving_transfer_account_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('receiving_transfer_account_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['giving_transfer_account_id'], ['transfer_account.id'], name='spend_approvals_giving_transfer_account_id_fkey'),
    sa.ForeignKeyConstraint(['receiving_transfer_account_id'], ['transfer_account.id'], name='spend_approvals_receiving_transfer_account_id_fkey'),
    sa.ForeignKeyConstraint(['token_id'], ['token.id'], name='spend_approvals_token_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='spend_approvals_pkey')
    )
    op.drop_table('spend_approval')
    # ### end Alembic commands ### 
Example #15
Source File: 778e1348250b_.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('chatbot_state_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('user_chatbot_state_id_fkey', 'user', 'chatbot_state', ['chatbot_state_id'], ['id'])
    op.create_table('chatbot_state',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('transfer_initialised', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('transfer_amount', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('prev_pin_failures', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('last_accessed', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('provider_message_id', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('target_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='chatbot_state_pkey')
    )
    # ### end Alembic commands ### 
Example #16
Source File: e44e075decdf_.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', 'primary_blockchain_address')
    op.drop_column('user', 'is_public')
    op.add_column('transfer_account', sa.Column('balance', sa.BIGINT(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'transfer_account', type_='foreignkey')
    op.drop_column('transfer_account', 'is_public')
    op.drop_column('transfer_account', 'exchange_contract_id')
    op.drop_column('transfer_account', '_balance_wei')
    op.drop_column('email_whitelist', 'is_public')
    op.add_column('credit_transfer', sa.Column('transfer_amount', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_column('credit_transfer', 'is_public')
    op.drop_column('credit_transfer', '_transfer_amount_wei')
    op.drop_column('blockchain_address', 'is_public')
    op.drop_table('exchange_contract_token_association_table')
    op.drop_index(op.f('ix_exchange_contract_contract_registry_blockchain_address'), table_name='exchange_contract')
    op.drop_index(op.f('ix_exchange_contract_blockchain_address'), table_name='exchange_contract')
    op.drop_table('exchange_contract')
    op.drop_table('exchange')
    # ### end Alembic commands ### 
Example #17
Source File: 1c89fa61f23e_.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('targeting_survey_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('user_targeting_survey_id_fkey', 'user', 'targeting_survey', ['targeting_survey_id'], ['id'])
    op.create_table('targeting_survey',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('number_people_household', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('number_below_adult_age_household', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('number_people_women_household', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('number_people_men_household', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('number_people_work_household', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('disabilities_household', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('long_term_illnesses_household', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='targeting_survey_pkey')
    )
    # ### end Alembic commands ### 
Example #18
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 #19
Source File: 0d6d3ce1654d_.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.create_table('custom_settings',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='custom_settings_pkey')
    )
    op.drop_table('settings')
    # ### end Alembic commands ### 
Example #20
Source File: test_autogen_diffs.py    From alembic with MIT License 5 votes vote down vote up
def test_custom_type_compare(self):
        class MyType(TypeDecorator):
            impl = Integer

            def compare_against_backend(self, dialect, conn_type):
                return isinstance(conn_type, Integer)

        ac = ops.AlterColumnOp("sometable", "somecol")
        autogenerate.compare._compare_type(
            self.autogen_context,
            ac,
            None,
            "sometable",
            "somecol",
            Column("somecol", INTEGER()),
            Column("somecol", MyType()),
        )

        assert not ac.has_changes()

        ac = ops.AlterColumnOp("sometable", "somecol")
        autogenerate.compare._compare_type(
            self.autogen_context,
            ac,
            None,
            "sometable",
            "somecol",
            Column("somecol", String()),
            Column("somecol", MyType()),
        )
        diff = ac.to_diff_tuple()
        eq_(diff[0][0:4], ("modify_type", None, "sometable", "somecol")) 
Example #21
Source File: 2ff46ae4b74c_.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('token', sa.Column('decimals', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_column('token', '_decimals')
    # ### end Alembic commands ### 
Example #22
Source File: 0045_billable_units.py    From notifications-api with MIT License 5 votes vote down vote up
def downgrade():
    op.add_column('notifications', sa.Column(
        'content_char_count',
        sa.INTEGER(),
        autoincrement=False,
        nullable=True)
    )
    op.add_column('notification_history', sa.Column(
        'content_char_count',
        sa.INTEGER(),
        autoincrement=False,
        nullable=True)
    )

    conn = op.get_bind()

    # caveats
    # only adjusts notifications for services that have never been in research mode. On live, research mode was
    # limited to only services that we have set up ourselves
    billable_services = conn.execute('''
        SELECT id FROM services_history WHERE id not in (select id from services_history where research_mode)
    ''')
    # set to 'null' if there are no billable services so we don't get a syntax error in the update statement
    service_ids = ','.join("'{}'".format(service.id) for service in billable_services) or 'null'

    # caveats:
    # only approximates character counts - billable * 153 to get at least a decent ballpark
    # research mode messages assumed to be one message length
    update_statement = '''
        UPDATE {}
        SET content_char_count = GREATEST(billable_units, 1) * 150
        WHERE service_id in ({})
        AND notification_type = 'sms'
    '''

    conn = op.get_bind()
    conn.execute(update_statement.format('notifications', service_ids))
    conn.execute(update_statement.format('notification_history', service_ids))
    op.drop_column('notifications', 'billable_units')
    op.drop_column('notification_history', 'billable_units') 
Example #23
Source File: ead35f7d446c_.py    From contentdb with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('package', 'forums',
               existing_type=sa.INTEGER(),
               nullable=True)
    # ### end Alembic commands ### 
Example #24
Source File: 0250_drop_stats_template_table.py    From notifications-api with MIT License 5 votes vote down vote up
def downgrade():
    op.create_table('stats_template_usage_by_month',
                    sa.Column('template_id', postgresql.UUID(), autoincrement=False, nullable=False),
                    sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=False),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=False),
                    sa.Column('count', sa.INTEGER(), autoincrement=False, nullable=False),
                    sa.ForeignKeyConstraint(['template_id'], ['templates.id'],
                                            name='stats_template_usage_by_month_template_id_fkey'),
                    sa.PrimaryKeyConstraint('template_id', 'month', 'year', name='stats_template_usage_by_month_pkey')
                    )
    op.create_index('ix_stats_template_usage_by_month_year', 'stats_template_usage_by_month', ['year'], unique=False)
    op.create_index('ix_stats_template_usage_by_month_template_id', 'stats_template_usage_by_month', ['template_id'],
                    unique=False)
    op.create_index('ix_stats_template_usage_by_month_month', 'stats_template_usage_by_month', ['month'], unique=False) 
Example #25
Source File: 5ac46b68b339_.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.create_table('public_serial_number',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('public_serial_number', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('PIN', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('nfc_serial_number', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='public_serial_number_pkey')
    )
    op.drop_table('transfer_card')
    # ### end Alembic commands ### 
Example #26
Source File: ead35f7d446c_.py    From contentdb with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('package', 'forums',
               existing_type=sa.INTEGER(),
               nullable=False)
    # ### end Alembic commands ### 
Example #27
Source File: 65b082beab7b_.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('pin_to_public_id', sa.Column('PIN', sa.INTEGER(), autoincrement=False, nullable=True))
    # ### end Alembic commands ### 
Example #28
Source File: ad3878bc0030_.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('user', sa.Column('organisation_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('user_organisation_id_fkey', 'user', 'organisation', ['organisation_id'], ['id'])
    op.add_column('transfer_account', sa.Column('organisation_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('transfer_account_organisation_id_fkey', 'transfer_account', 'organisation', ['organisation_id'], ['id'])
    op.add_column('credit_transfer', sa.Column('organisation_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('credit_transfer_organisation_id_fkey', 'credit_transfer', 'organisation', ['organisation_id'], ['id'])
    # ### end Alembic commands ### 
Example #29
Source File: 2be22b2cff07_.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.create_table('uploaded_image',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('filename', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('credit_transfer_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('image_type', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['credit_transfer_id'], ['credit_transfer.id'], name='uploaded_image_credit_transfer_id_fkey'),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='uploaded_image_user_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='uploaded_image_pkey')
    )
    op.create_table('uploaded_document',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('filename', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('file_type', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('user_filename', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('reference', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('kyc_application_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['kyc_application_id'], ['kyc_application.id'], name='uploaded_document_kyc_application_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='uploaded_document_pkey')
    )
    op.drop_table('uploaded_resource')
    # ### end Alembic commands ### 
Example #30
Source File: test_autogen_diffs.py    From alembic with MIT License 5 votes vote down vote up
def test_uses_custom_compare_type_function(self):
        my_compare_type = mock.Mock()
        self.context._user_compare_type = my_compare_type

        uo = ops.UpgradeOps(ops=[])

        ctx = self.autogen_context
        autogenerate._produce_net_changes(ctx, uo)

        first_table = self.m2.tables["sometable"]
        first_column = first_table.columns["id"]

        eq_(len(my_compare_type.mock_calls), 2)

        # We'll just test the first call
        _, args, _ = my_compare_type.mock_calls[0]
        (
            context,
            inspected_column,
            metadata_column,
            inspected_type,
            metadata_type,
        ) = args
        eq_(context, self.context)
        eq_(metadata_column, first_column)
        eq_(metadata_type, first_column.type)
        eq_(inspected_column.name, first_column.name)
        eq_(type(inspected_type), INTEGER)