Python sqlalchemy.ForeignKeyConstraint() Examples
The following are 30
code examples of sqlalchemy.ForeignKeyConstraint().
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
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: 551c4e6d4a8b_.py From app with MIT License | 6 votes |
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 #2
Source File: 20bcb4b2673c_.py From gitlab-tools with GNU General Public License v3.0 | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('task_result', sa.Column('updated', sa.DateTime(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('pull_mirror_id', sa.Integer(), nullable=True), sa.Column('push_mirror_id', sa.Integer(), nullable=True), sa.Column('task_id', sa.String(length=155), nullable=True), sa.Column('status', sa.String(length=50), nullable=True), sa.Column('task_name', sa.String(length=255), nullable=True), sa.Column('invoked_by', sa.Integer(), nullable=True), sa.Column('result', sa.PickleType(), nullable=True), sa.Column('date_done', sa.DateTime(), nullable=True), sa.Column('traceback', sa.Text(), nullable=True), sa.ForeignKeyConstraint(['pull_mirror_id'], ['pull_mirror.id'], ), sa.ForeignKeyConstraint(['push_mirror_id'], ['push_mirror.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('task_id') ) op.create_index(op.f('ix_task_result_pull_mirror_id'), 'task_result', ['pull_mirror_id'], unique=False) op.create_index(op.f('ix_task_result_push_mirror_id'), 'task_result', ['push_mirror_id'], unique=False) # ### end Alembic commands ###
Example #3
Source File: 2020_031416_11a35b448f83_.py From app with MIT License | 6 votes |
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 #4
Source File: fa75d46a7f11_add_port_pair_group_params.py From networking-sfc with Apache License 2.0 | 6 votes |
def upgrade(): op.create_table('sfc_port_pair_group_params', sa.Column('keyword', sa.String(length=255), nullable=False), sa.Column('value', sa.String(length=255), nullable=True), sa.Column('pair_group_id', sa.String(length=36), nullable=False), sa.ForeignKeyConstraint(['pair_group_id'], ['sfc_port_pair_groups.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('keyword', 'pair_group_id'), mysql_engine='InnoDB' ) op.add_column('sfc_port_chains', sa.Column('chain_id', sa.Integer(), nullable=False)) op.create_unique_constraint(None, 'sfc_port_chains', ['chain_id']) op.add_column('sfc_port_pair_groups', sa.Column('group_id', sa.Integer(), nullable=False)) op.create_unique_constraint(None, 'sfc_port_pair_groups', ['group_id'])
Example #5
Source File: b6bfca998431_add_container_actions_events_table.py From zun with Apache License 2.0 | 6 votes |
def upgrade(): op.create_table( 'container_actions_events', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('event', sa.String(length=255), nullable=True), sa.Column('action_id', sa.Integer(), nullable=False), sa.Column('start_time', sa.DateTime(), nullable=True), sa.Column('finish_time', sa.DateTime(), nullable=True), sa.Column('result', sa.String(length=255), nullable=True), sa.Column('traceback', sa.Text(), nullable=True), sa.Column('details', sa.Text(), nullable=True), sa.ForeignKeyConstraint(['action_id'], ['container_actions.id'], ), sa.PrimaryKeyConstraint('id') )
Example #6
Source File: d295f8dcfa64_initial_revision.py From maubot with GNU Affero General Public License v3.0 | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('client', sa.Column('id', sa.String(length=255), nullable=False), sa.Column('homeserver', sa.String(length=255), nullable=False), sa.Column('access_token', sa.Text(), nullable=False), sa.Column('enabled', sa.Boolean(), nullable=False), sa.Column('next_batch', sa.String(length=255), nullable=False), sa.Column('filter_id', sa.String(length=255), nullable=False), sa.Column('sync', sa.Boolean(), nullable=False), sa.Column('autojoin', sa.Boolean(), nullable=False), sa.Column('displayname', sa.String(length=255), nullable=False), sa.Column('avatar_url', sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_table('plugin', sa.Column('id', sa.String(length=255), nullable=False), sa.Column('type', sa.String(length=255), nullable=False), sa.Column('enabled', sa.Boolean(), nullable=False), sa.Column('primary_user', sa.String(length=255), nullable=False), sa.Column('config', sa.Text(), nullable=False), sa.ForeignKeyConstraint(['primary_user'], ['client.id'], onupdate='CASCADE', ondelete='RESTRICT'), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ###
Example #7
Source File: cf46a28f46bc_add_container_actions_table.py From zun with Apache License 2.0 | 6 votes |
def upgrade(): op.create_table( 'container_actions', sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('action', sa.String(length=255), nullable=True), sa.Column('container_uuid', sa.String(length=36), nullable=False), sa.Column('request_id', sa.String(length=255), nullable=True), sa.Column('user_id', sa.String(length=255), nullable=True), sa.Column('project_id', sa.String(length=255), nullable=True), sa.Column('start_time', sa.DateTime(), nullable=True), sa.Column('finish_time', sa.DateTime(), nullable=True), sa.Column('message', sa.String(length=255), nullable=True), sa.Index('container_uuid_idx', 'container_uuid'), sa.Index('request_id_idx', 'request_id'), sa.ForeignKeyConstraint(['container_uuid'], ['container.uuid'], ), sa.PrimaryKeyConstraint('id') )
Example #8
Source File: 131ad2dc5bbd_table_for_no_new_branches_hook.py From pagure with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: 2020_052419_f680032cc361_.py From app with MIT License | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('fido', 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('credential_id', sa.String(), nullable=False), sa.Column('uuid', sa.String(), nullable=False), sa.Column('public_key', sa.String(), nullable=False), sa.Column('sign_count', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=128), nullable=False), sa.ForeignKeyConstraint(['uuid'], ['users.fido_uuid'], ondelete='cascade'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('public_key') ) op.create_index(op.f('ix_fido_credential_id'), 'fido', ['credential_id'], unique=True) op.drop_constraint('users_fido_credential_id_key', 'users', type_='unique') op.drop_constraint('users_fido_pk_key', 'users', type_='unique') op.drop_column('users', 'fido_sign_count') op.drop_column('users', 'fido_pk') op.drop_column('users', 'fido_credential_id') # ### end Alembic commands ###
Example #10
Source File: 2020_041911_dd911f880b75_.py From app with MIT License | 6 votes |
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 #11
Source File: dadfc046c4cb_.py From SempoBlockchain with GNU General Public License v3.0 | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('referral', sa.Column('id', sa.Integer(), nullable=False), sa.Column('authorising_user_id', sa.Integer(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('updated', sa.DateTime(), nullable=True), sa.Column('first_name', sa.String(), nullable=True), sa.Column('last_name', sa.String(), nullable=True), sa.Column('reason', sa.String(), nullable=True), sa.Column('_phone', sa.String(), nullable=True), sa.Column('referring_user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['referring_user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ###
Example #12
Source File: 902a827bc3e4_.py From SempoBlockchain with GNU General Public License v3.0 | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('pin_to_public_id', sa.Column('id', sa.Integer(), nullable=False), sa.Column('PIN', sa.Integer(), nullable=True), sa.Column('public_id', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_table('feedback', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('rating', sa.Float(), nullable=True), sa.Column('additional_information', sa.String(), nullable=True), sa.Column('transfer_account_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['transfer_account_id'], ['transfer_account.id'], ), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ###
Example #13
Source File: c9db3658816a_.py From SempoBlockchain with GNU General Public License v3.0 | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('spend_approval', sa.Column('id', sa.Integer(), nullable=False), sa.Column('authorising_user_id', sa.Integer(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('updated', sa.DateTime(), nullable=True), sa.Column('eth_send_task_id', sa.Integer(), nullable=True), sa.Column('approval_task_id', sa.Integer(), nullable=True), sa.Column('receiving_address', sa.String(), nullable=True), sa.Column('token_id', sa.Integer(), nullable=True), sa.Column('giving_transfer_account_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['giving_transfer_account_id'], ['transfer_account.id'], ), sa.ForeignKeyConstraint(['token_id'], ['token.id'], ), sa.PrimaryKeyConstraint('id') ) op.drop_table('spend_approvals') op.add_column('organisation', sa.Column('system_blockchain_address', sa.String(), nullable=True)) # ### end Alembic commands ###
Example #14
Source File: c9db3658816a_.py From SempoBlockchain with GNU General Public License v3.0 | 6 votes |
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: 3ebfbaeb76c0_.py From app with MIT License | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('email_change', 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('new_email', sa.String(length=128), nullable=False), sa.Column('code', sa.String(length=128), nullable=False), sa.Column('expired', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code'), sa.UniqueConstraint('new_email') ) op.create_index(op.f('ix_email_change_user_id'), 'email_change', ['user_id'], unique=True) # ### end Alembic commands ###
Example #16
Source File: 35aa30ce8a33_.py From SempoBlockchain with GNU General Public License v3.0 | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('custom_attribute_user_storage', sa.Column('id', sa.Integer(), nullable=False), sa.Column('authorising_user_id', sa.Integer(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('updated', sa.DateTime(), nullable=True), sa.Column('name', sa.String(), nullable=True), sa.Column('value', sa.String(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('uploaded_image_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) op.add_column('user', sa.Column('preferred_language', sa.String(), nullable=True)) op.drop_column('user', 'custom_attributes') # ### end Alembic commands ###
Example #17
Source File: 2020_022722_75093e7ded27_.py From app with MIT License | 6 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('social_auth', 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('social', sa.String(length=128), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('user_id', 'social', name='uq_social_auth') ) op.alter_column('users', 'password', existing_type=sa.VARCHAR(length=128), nullable=True) op.alter_column('users', 'salt', existing_type=sa.VARCHAR(length=128), nullable=True) # ### end Alembic commands ###
Example #18
Source File: d68a2d971b70_.py From app with MIT License | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('deleted_alias', 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=128), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('user_id') ) # ### end Alembic commands ###
Example #19
Source File: 00001_fba1df4514fa_starting.py From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('web_page_history', sa.Column('id', sa.Integer(), nullable=False), sa.Column('errno', sa.Integer(), nullable=True), sa.Column('url', sa.Text(), nullable=False), sa.Column('file', sa.Integer(), nullable=True), sa.Column('distance', sa.Integer(), nullable=False), sa.Column('is_text', sa.Boolean(), nullable=True), sa.Column('title', citext.CIText(), nullable=True), sa.Column('mimetype', sa.Text(), nullable=True), sa.Column('content', sa.Text(), nullable=True), sa.Column('fetchtime', sa.DateTime(), nullable=True), sa.Column('addtime', sa.DateTime(), nullable=True), sa.Column('tsv_content', sqlalchemy_utils.types.ts_vector.TSVectorType(), nullable=True), sa.Column('root_rel', sa.Integer(), nullable=False), sa.Column('newer_rel', sa.Integer(), nullable=True), sa.Column('older_rel', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['file'], ['web_files.id'], ), sa.ForeignKeyConstraint(['newer_rel'], ['web_page_history.id'], ), sa.ForeignKeyConstraint(['older_rel'], ['web_page_history.id'], ), sa.ForeignKeyConstraint(['root_rel'], ['web_pages.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_web_page_history_distance'), 'web_page_history', ['distance'], unique=False) op.create_index('ix_web_page_history_tsv_content', 'web_page_history', ['tsv_content'], unique=False, postgresql_using='gin') op.create_index(op.f('ix_web_page_history_url'), 'web_page_history', ['url'], unique=True) ### end Alembic commands ###
Example #20
Source File: 5f4b4c9f586d_.py From SempoBlockchain with GNU General Public License v3.0 | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('ussd_menu', sa.Column('id', sa.Integer(), nullable=False), sa.Column('authorising_user_id', sa.Integer(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('updated', sa.DateTime(), nullable=True), sa.Column('name', sa.String(), nullable=False), sa.Column('description', sa.String(), nullable=True), sa.Column('parent_id', sa.Integer(), nullable=True), sa.Column('display_key', sa.String(), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ussd_menu_name'), 'ussd_menu', ['name'], unique=True) op.create_table('ussd_session', sa.Column('id', sa.Integer(), nullable=False), sa.Column('authorising_user_id', sa.Integer(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('updated', sa.DateTime(), nullable=True), sa.Column('session_id', sa.String(), nullable=False), sa.Column('service_code', sa.String(), nullable=False), sa.Column('msisdn', sa.String(), nullable=False), sa.Column('user_input', sa.String(), nullable=True), sa.Column('state', sa.String(), nullable=False), sa.Column('session_data', postgresql.JSON(astext_type=sa.Text()), nullable=True), sa.Column('ussd_menu_id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.ForeignKeyConstraint(['ussd_menu_id'], ['ussd_menu.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_ussd_session_session_id'), 'ussd_session', ['session_id'], unique=True) op.drop_index('ix_ussd_sessions_session_id', table_name='ussd_sessions') op.drop_table('ussd_sessions') op.drop_index('ix_ussd_menus_name', table_name='ussd_menus') op.drop_table('ussd_menus') # ### end Alembic commands ###
Example #21
Source File: test_suite.py From sqlalchemy-hana with Apache License 2.0 | 5 votes |
def test_get_foreign_key_options(self): # this tests needs to be overwritten, because # In no case in SQLAlchemy-hana an empty dictionary is returned for foreign key options. # Also if the user does not explicitly mention the referential actions to be used in the # create table statement, the default values of the referential actions in HANA (RESTRICT) are reflected. meta = self.metadata Table( 'x', meta, Column('id', Integer, primary_key=True), test_needs_fk=True ) Table('table', meta, Column('id', Integer, primary_key=True), Column('x_id', Integer, sa.ForeignKey('x.id', name='xid')), Column('test', String(10)), test_needs_fk=True) Table('user', meta, Column('id', Integer, primary_key=True), Column('name', String(50), nullable=False), Column('tid', Integer), sa.ForeignKeyConstraint( ['tid'], ['table.id'], name='myfk', onupdate="SET NULL", ondelete="CASCADE"), test_needs_fk=True) meta.create_all() insp = inspect(meta.bind) opts = insp.get_foreign_keys('user')[0]['options'] eq_( dict( (k, opts[k]) for k in opts if opts[k] ), {'onupdate': 'SET NULL', 'ondelete': 'CASCADE'} )
Example #22
Source File: 00018_8ae5aae58f62_.py From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('nu_release_item', sa.Column('id', sa.BigInteger(), nullable=False), sa.Column('validated', sa.Boolean(), nullable=False), sa.Column('actual_target', sa.Text(), nullable=True), sa.Column('seriesname', sa.Text(), nullable=False), sa.Column('releaseinfo', sa.Text(), nullable=True), sa.Column('groupinfo', sa.Text(), nullable=False), sa.Column('referrer', sa.Text(), nullable=False), sa.Column('outbound_wrapper', sa.Text(), nullable=False), sa.Column('first_seen', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('seriesname', 'releaseinfo', 'groupinfo', 'outbound_wrapper', 'actual_target') ) op.create_index(op.f('ix_nu_release_item_groupinfo'), 'nu_release_item', ['groupinfo'], unique=False) op.create_index(op.f('ix_nu_release_item_seriesname'), 'nu_release_item', ['seriesname'], unique=False) op.create_table('nu_resolved_outbound', sa.Column('id', sa.BigInteger(), nullable=False), sa.Column('parent', sa.BigInteger(), nullable=False), sa.Column('client_id', sa.Text(), nullable=False), sa.Column('client_key', sa.Text(), nullable=False), sa.Column('actual_target', sa.Text(), nullable=False), sa.Column('fetched_on', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['parent'], ['nu_release_item.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('client_id', 'client_key', 'actual_target') ) op.create_index(op.f('ix_nu_resolved_outbound_client_id'), 'nu_resolved_outbound', ['client_id'], unique=False) op.create_index(op.f('ix_nu_resolved_outbound_client_key'), 'nu_resolved_outbound', ['client_key'], unique=False) op.create_index(op.f('ix_nu_resolved_outbound_parent'), 'nu_resolved_outbound', ['parent'], unique=False) ### end Alembic commands ###
Example #23
Source File: 9768e6a66c9_flowclassifier_data_model.py From networking-sfc with Apache License 2.0 | 5 votes |
def upgrade(): op.create_table( 'sfc_flow_classifiers', sa.Column('tenant_id', sa.String(length=255), nullable=True, index=True), sa.Column('id', sa.String(length=36), nullable=False), sa.Column('name', sa.String(length=255), nullable=True), sa.Column('ethertype', sa.String(length=40), nullable=True), sa.Column('protocol', sa.String(length=40), nullable=True), sa.Column('description', sa.String(length=255), nullable=True), sa.Column('source_port_range_min', sa.Integer(), nullable=True), sa.Column('source_port_range_max', sa.Integer(), nullable=True), sa.Column('destination_port_range_min', sa.Integer(), nullable=True), sa.Column('destination_port_range_max', sa.Integer(), nullable=True), sa.Column('source_ip_prefix', sa.String(length=255), nullable=True), sa.Column('destination_ip_prefix', sa.String(length=255), nullable=True), sa.Column('logical_source_port', sa.String(length=36), nullable=False), sa.Column('logical_destination_port', sa.String(length=36), nullable=True), sa.ForeignKeyConstraint(['logical_source_port'], ['ports.id'], ondelete='RESTRICT'), sa.ForeignKeyConstraint(['logical_destination_port'], ['ports.id'], ondelete='RESTRICT'), sa.PrimaryKeyConstraint('id') ) op.create_table( 'sfc_flow_classifier_l7_parameters', sa.Column('keyword', sa.String(length=255), nullable=False), sa.Column('value', sa.String(length=255), nullable=True), sa.Column('classifier_id', sa.String(length=36), nullable=False), sa.ForeignKeyConstraint(['classifier_id'], ['sfc_flow_classifiers.id'], ), sa.PrimaryKeyConstraint('keyword', 'classifier_id') )
Example #24
Source File: 7ea324d0535b_vfolder_and_kernel.py From backend.ai-manager with GNU Lesser General Public License v3.0 | 5 votes |
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('kernels', sa.Column('agent_id', sa.VARCHAR(), autoincrement=False, nullable=True)) op.drop_constraint(op.f('fk_kernels_agent_agents'), 'kernels', type_='foreignkey') op.drop_index(op.f('ix_kernels_terminated_at'), table_name='kernels') op.drop_index(op.f('ix_kernels_status'), table_name='kernels') op.drop_index(op.f('ix_kernels_created_at'), table_name='kernels') op.drop_column('kernels', 'status_info') op.drop_column('kernels', 'num_queries') op.drop_column('kernels', 'net_tx_bytes') op.drop_column('kernels', 'net_rx_bytes') op.drop_column('kernels', 'max_mem_bytes') op.drop_column('kernels', 'io_write_bytes') op.drop_column('kernels', 'io_read_bytes') op.drop_column('kernels', 'cur_mem_bytes') op.drop_column('kernels', 'cpu_used') op.drop_column('kernels', 'allocated_cores') op.drop_column('kernels', 'agent') op.create_table( 'usage', sa.Column('id', postgresql.UUID(), server_default=sa.text('uuid_generate_v4()'), autoincrement=False, nullable=False), sa.Column('access_key_id', sa.VARCHAR(length=20), autoincrement=False, nullable=True), sa.Column('kernel_type', sa.VARCHAR(), autoincrement=False, nullable=True), sa.Column('kernel_id', sa.VARCHAR(), autoincrement=False, nullable=True), sa.Column('started_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), sa.Column('terminated_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), sa.Column('cpu_used', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True), sa.Column('mem_used', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True), sa.Column('io_used', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True), sa.Column('net_used', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['access_key_id'], ['keypairs.access_key'], name='fk_usage_access_key_id_keypairs'), sa.PrimaryKeyConstraint('id', name='pk_usage') ) op.drop_table('vfolder_attachment') op.drop_table('vfolders') op.drop_table('agents') # ### end Alembic commands ###
Example #25
Source File: 4a640c170d02_.py From app with MIT License | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('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('cancel_url', sa.String(length=1024), nullable=False), sa.Column('update_url', sa.String(length=1024), nullable=False), sa.Column('subscription_id', sa.String(length=1024), nullable=False), sa.Column('event_time', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False), sa.Column('next_bill_date', sa.Date(), nullable=False), sa.Column('cancelled', sa.Boolean(), nullable=False), sa.Column('plan', sa.Enum('monthly', 'yearly', name='planenum2'), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('subscription_id'), sa.UniqueConstraint('user_id') ) op.add_column('users', sa.Column('trial_expiration', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True)) op.drop_column('users', 'plan_expiration') op.drop_column('users', 'plan') op.drop_column('users', 'promo_codes') # ### end Alembic commands ###
Example #26
Source File: 15c488d628b_.py From beavy with Mozilla Public License 2.0 | 5 votes |
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('private_message_participants', sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('pm_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['pm_id'], ['objects.id'], ), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ) ) op.add_column('objects', sa.Column('title', sa.String(length=255), nullable=False)) ### end Alembic commands ###
Example #27
Source File: 2020_052312_0e08145f0499_.py From app with MIT License | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('domain_deleted_alias', 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('email', sa.String(length=256), nullable=False), sa.Column('domain_id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['domain_id'], ['custom_domain.id'], ondelete='cascade'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('domain_id', 'email', name='uq_domain_trash') ) # ### end Alembic commands ###
Example #28
Source File: 5fa68bafae72_.py From app with MIT License | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('forward_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('gen_email_id', sa.Integer(), nullable=False), sa.Column('website_email', sa.String(length=128), nullable=False), sa.Column('reply_email', sa.String(length=128), nullable=False), sa.ForeignKeyConstraint(['gen_email_id'], ['gen_email.id'], ondelete='cascade'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('gen_email_id', 'website_email', name='uq_forward_email') ) # ### end Alembic commands ###
Example #29
Source File: b20ee72fd9a4_.py From app with MIT License | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('partner', 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('email', sa.String(length=128), nullable=True), sa.Column('name', sa.String(length=128), nullable=True), sa.Column('website', sa.String(length=1024), nullable=True), sa.Column('additional_information', sa.Text(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ###
Example #30
Source File: 2020_040922_ea30c0b5b2e3_.py From app with MIT License | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('referral', 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('code', sa.String(length=128), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.add_column('users', sa.Column('referral_id', sa.Integer(), nullable=True)) op.create_foreign_key(None, 'users', 'referral', ['referral_id'], ['id']) # ### end Alembic commands ###