How to use the sqlalchemy.PrimaryKeyConstraint function in SQLAlchemy

To help you get started, we’ve selected a few SQLAlchemy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quantifiedcode / checkmate / checkmate / migrations / versions / 14361ae029cf_initial_db_layout.py View on Github external
op.create_index(op.f('ix_gitsnapshot_updated_at'), 'gitsnapshot', ['updated_at'], unique=False)
    op.create_table('issueoccurrence',
    sa.Column('data', sa.LargeBinary(), nullable=True),
    sa.Column('pk', sa.VARCHAR(length=60), nullable=False),
    sa.Column('sequence', sa.Integer(), nullable=True),
    sa.Column('to_column', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('to_row', sa.Integer(), nullable=True),
    sa.Column('file_revision', sa.VARCHAR(length=60), nullable=True),
    sa.Column('from_row', sa.Integer(), nullable=True),
    sa.Column('issue', sa.VARCHAR(length=60), nullable=True),
    sa.Column('from_column', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['file_revision'], [u'filerevision.pk'], name=u'issueoccurrence_filerevision_file_revision', ondelete=u'CASCADE'),
    sa.ForeignKeyConstraint(['issue'], ['issue.pk'], name='issueoccurrence_issue_issue', ondelete=u'CASCADE'),
    sa.PrimaryKeyConstraint('pk')
    )
    op.create_index(op.f('ix_issueoccurrence_created_at'), 'issueoccurrence', ['created_at'], unique=False)
    op.create_index(op.f('ix_issueoccurrence_file_revision'), 'issueoccurrence', ['file_revision'], unique=False)
    op.create_index(op.f('ix_issueoccurrence_issue'), 'issueoccurrence', ['issue'], unique=False)
    op.create_index(op.f('ix_issueoccurrence_pk'), 'issueoccurrence', ['pk'], unique=False)
    op.create_index(op.f('ix_issueoccurrence_updated_at'), 'issueoccurrence', ['updated_at'], unique=False)
    op.create_table('snapshot_filerevision',
    sa.Column('pk_filerevision', sa.VARCHAR(length=60), nullable=True),
    sa.Column('pk_snapshot', sa.VARCHAR(length=60), nullable=True),
    sa.ForeignKeyConstraint(['pk_filerevision'], [u'filerevision.pk'], name=u'snapshot_filerevision_pk_filerevision', ondelete=u'CASCADE'),
    sa.ForeignKeyConstraint(['pk_snapshot'], ['snapshot.pk'], name=u'snapshot_filerevision_pk_snapshot', ondelete=u'CASCADE'),
    sa.UniqueConstraint('pk_filerevision', 'pk_snapshot', name=u'snapshot_filerevision_file_revisions_unique')
    )
    op.create_index(op.f('ix_snapshot_filerevision_pk_filerevision'), 'snapshot_filerevision', ['pk_filerevision'], unique=False)
    op.create_index(op.f('ix_snapshot_filerevision_pk_snapshot'), 'snapshot_filerevision', ['pk_snapshot'], unique=False)
    op.create_table('difffilerevision',
github KanColleTool / kcsrv / migrations / versions / 1f4f8dd0a86_initial_remodel_migration.py View on Github external
op.create_index(op.f('ix_recipe_max_resources_id'), 'recipe', ['max_resources_id'], unique=False)
    op.create_index(op.f('ix_recipe_min_resources_id'), 'recipe', ['min_resources_id'], unique=False)
    op.create_table('dock', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('number', sa.Integer(), nullable=True), sa.Column('type_', sa.Integer(), nullable=True),
        sa.Column('state', sa.Integer(), nullable=True), sa.Column('complete', sa.BigInteger(), nullable=True),
        sa.Column('admiral_id', sa.Integer(), nullable=True), sa.Column('kanmusu_id', sa.Integer(), nullable=True),
        sa.Column('resources_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['admiral_id'], ['admiral.id'], ),
        sa.ForeignKeyConstraint(['kanmusu_id'], ['kanmusu.id'], ),
        sa.ForeignKeyConstraint(['resources_id'], ['resources.id'], ), sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_dock_resources_id'), 'dock', ['resources_id'], unique=False)
    op.create_table('kanmusu_equipment', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('slot', sa.Integer(), nullable=True), sa.Column('kanmusu_id', sa.Integer(), nullable=True),
        sa.Column('admiral_equipment_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['admiral_equipment_id'], ['admiral_equipment.id'], ),
        sa.ForeignKeyConstraint(['kanmusu_id'], ['kanmusu.id'], ), sa.PrimaryKeyConstraint('id'))
    ### end Alembic commands ###
github pyjobs / web / pyjobs_web / migration / versions / 3056be06bd1c_add_crawl_log_table.py View on Github external
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('crawl_log',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('source', sa.String(length=64), nullable=True),
    sa.Column('message', sa.String(length=1024), nullable=False),
    sa.Column('datetime', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
github openstack / neutron / neutron / db / migration / alembic_migrations / ml2_init_ops.py View on Github external
sa.PrimaryKeyConstraint('physical_network'))

    op.create_table(
        'ml2_network_segments',
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('network_id', sa.String(length=36), nullable=False),
        sa.Column('network_type', sa.String(length=32), nullable=False),
        sa.Column('physical_network', sa.String(length=64), nullable=True),
        sa.Column('segmentation_id', sa.Integer(), nullable=True),
        sa.Column('is_dynamic', sa.Boolean(), nullable=False,
                  server_default=sa.sql.false()),
        sa.Column('segment_index', sa.Integer(), nullable=False,
                  server_default='0'),
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'))

    op.create_table(
        'ml2_port_bindings',
        sa.Column('port_id', sa.String(length=36), nullable=False),
        sa.Column('host', sa.String(length=255), nullable=False,
                  server_default=''),
        sa.Column('vif_type', sa.String(length=64), nullable=False),
        sa.Column('vnic_type', sa.String(length=64), nullable=False,
                  server_default='normal'),
        sa.Column('profile', sa.String(length=4095), nullable=False,
                  server_default=''),
        sa.Column('vif_details', sa.String(length=4095), nullable=False,
                  server_default=''),
        sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('port_id'))
github corpus-christi / corpus-christi / api / migrations / versions / acab0c32ccb9_initial_migration.py View on Github external
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('i18n_key',
    sa.Column('id', sa.String(length=32), nullable=False),
    sa.Column('desc', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('i18n_locale',
    sa.Column('code', sa.String(length=5), nullable=False),
    sa.Column('desc', sa.String(length=64), nullable=False),
    sa.PrimaryKeyConstraint('code')
    )
    op.create_table('i18n_language',
    sa.Column('code', sa.String(length=2), nullable=False),
    sa.Column('name_i18n', sa.String(length=32), nullable=False),
    sa.ForeignKeyConstraint(['name_i18n'], ['i18n_key.id'], ),
    sa.PrimaryKeyConstraint('code')
    )
    op.create_table('i18n_value',
    sa.Column('key_id', sa.String(length=32), nullable=False),
    sa.Column('locale_code', sa.String(length=5), nullable=False),
    sa.Column('gloss', sa.Text(), nullable=False),
    sa.ForeignKeyConstraint(['key_id'], ['i18n_key.id'], ),
    sa.ForeignKeyConstraint(['locale_code'], ['i18n_locale.code'], ),
    sa.PrimaryKeyConstraint('key_id', 'locale_code')
    )
    op.create_table('places_country',
github mitmedialab / CivilServant / alembic / versions / fac8f8df46b7_add_subreddit_subreddit_page_post_tables.py View on Github external
sa.UniqueConstraint('id')
    )
    op.create_table('subreddit_page',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('page_type', sa.Integer(), nullable=True),
    sa.Column('page_data', mysql.MEDIUMTEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('post',
    sa.Column('id', sa.String(length=32), autoincrement=False, nullable=False),
    sa.Column('subreddit_id', sa.String(length=32), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('post_data', mysql.MEDIUMTEXT(), nullable=True),
    sa.ForeignKeyConstraint(['subreddit_id'], ['subreddit.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('id')
    )
github cmdmnt / commandment / commandment / alembic / versions / 71818e983100_create_application_sources_table.py View on Github external
def upgrade():
    op.create_table('application_sources',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(), nullable=True),
                    sa.Column('source_type', sa.Enum('S3', 'Munki', name='appsourcetype'), nullable=True),
                    sa.Column('endpoint', sa.String(), nullable=True),
                    sa.Column('mount_uri', sa.String(), nullable=True),
                    sa.Column('use_ssl', sa.Boolean(), nullable=True),
                    sa.Column('access_key', sa.String(), nullable=True),
                    sa.Column('secret_key', sa.String(), nullable=True),
                    sa.Column('bucket', sa.String(), nullable=True),
                    sa.PrimaryKeyConstraint('id')
                    )
github mozilla-services / socorro / alembic / versions / 732abe64c5a_fixes_bug_1136711_deprecate_bixie.py View on Github external
sa.ForeignKeyConstraint(['error_message_id'], [u'bixie.error_messages.id'], name=u'error_message_products_error_message_id_fkey'),
    sa.PrimaryKeyConstraint('id', name=u'error_message_products_pkey'),
    schema='bixie'
    )
    op.create_table('user_agents',
    sa.Column('id', sa.INTEGER(), sa.Sequence('bixie.user_agents_id_seq'), nullable=False),
    sa.Column('error_message_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['error_message_id'], [u'bixie.error_messages.id'], name=u'user_agents_error_message_id_fkey'),
    sa.PrimaryKeyConstraint('id', name=u'user_agents_pkey'),
    schema='bixie'
    )
    op.create_table('release_channels',
    sa.Column('id', sa.INTEGER(), sa.Sequence('bixie.release_channels_id_seq'), nullable=False),
    sa.Column('name', citexttype.CitextType, autoincrement=False, nullable=False),
    sa.Column('sort', sa.TEXT(), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id', name=u'release_channels_pkey'),
    schema='bixie'
    )
    op.create_table('product_release_channels',
    sa.Column('id', sa.INTEGER(), sa.Sequence('bixie.product_release_channels_id_seq'), nullable=False),
    sa.Column('release_channel_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('product_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['release_channel_id'], [u'bixie.release_channels.id'], name=u'product_release_channels_release_channel_id_fkey'),
    sa.PrimaryKeyConstraint('id', name=u'product_release_channels_pkey'),
    schema='bixie'
    )
    op.create_table('crashes_normalized',
    sa.Column('crash_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('signature_id', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('error_message_id', jsontype.JsonType, autoincrement=False, nullable=False),
    sa.Column('product_id', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('user_agent_id', sa.TEXT(), autoincrement=False, nullable=True),
github openstack / neutron / neutron / db / migration / alembic_migrations / versions / folsom_initial.py View on Github external
def upgrade_meta():
    op.create_table(
        'networkflavors',
        sa.Column('flavor', sa.String(length=255)),
        sa.Column('network_id', sa.String(length=36), nullable=False),
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('network_id')
    )

    op.create_table(
        'routerflavors',
        sa.Column('flavor', sa.String(length=255)),
        sa.Column('router_id', sa.String(length=36), nullable=False),
        sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('router_id')
    )
github lahwaacz / wiki-scripts / ws / db / schema.py View on Github external
Column("old_text", UnicodeText, nullable=False),
        # MW incompatibility: there is no old_flags column because it is useless for us
        # (everything is utf-8, compression is done transparently by PostgreSQL, PHP
        # objects are not supported and we will never support external storage)
    )

    tagged_revision = Table("tagged_revision", metadata,
        Column("tgrev_tag_id", Integer, ForeignKey("tag.tag_id", ondelete="CASCADE", deferrable=True, initially="DEFERRED"), nullable=False),
        Column("tgrev_rev_id", Integer, ForeignKey("revision.rev_id", ondelete="CASCADE", deferrable=True, initially="DEFERRED")),
        PrimaryKeyConstraint("tgrev_tag_id", "tgrev_rev_id")
    )

    tagged_archived_revision = Table("tagged_archived_revision", metadata,
        Column("tgar_tag_id", Integer, ForeignKey("tag.tag_id", ondelete="CASCADE", deferrable=True, initially="DEFERRED"), nullable=False),
        Column("tgar_rev_id", Integer, ForeignKey("archive.ar_rev_id", ondelete="CASCADE", deferrable=True, initially="DEFERRED")),
        PrimaryKeyConstraint("tgar_tag_id", "tgar_rev_id")
    )