我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sqlalchemy.UniqueConstraint()。
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=64), nullable=True), sa.Column('default', sa.Boolean(), nullable=True), sa.Column('permissions', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=164), nullable=True), sa.Column('email', sa.String(length=164), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.Column('password_hash', sa.String(length=164), nullable=True), sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('episode', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(), nullable=False), sa.Column('link', sa.String(), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('published', sa.DateTime(), nullable=True), sa.Column('enclosure', sa.String(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('podcast_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('link'), sa.UniqueConstraint('title') ) op.create_index(op.f('ix_podcast_feed'), 'podcast', ['feed'], unique=True) op.create_index(op.f('ix_podcast_name'), 'podcast', ['name'], unique=True) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('role', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('description', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('email', sa.String(length=255), nullable=True), sa.Column('active', sa.Boolean(), nullable=True), sa.Column('confirmed_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email') ) op.create_table('roles_users', sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['role_id'], ['role.id'], ), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ) ) ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('hot_books', sa.Column('book_id', sa.Integer(), nullable=False), sa.Column('book_author', sa.Text(), nullable=True), sa.Column('book_cover', sa.Text(), nullable=True), sa.Column('book_rate', sa.Integer(), nullable=True), sa.Column('book_content', sa.Text(), nullable=True), sa.Column('book_publish', sa.Text(), nullable=True), sa.Column('book_last_number', sa.Integer(), nullable=True), sa.Column('book_key', sa.String(length=13), nullable=True), sa.Column('book_db_id', sa.Integer(), nullable=True), sa.Column('book_title', sa.Text(), nullable=True), sa.Column('book_place', sa.Text(), nullable=True), sa.Column('detail_data', sa.Text(), nullable=True), sa.Column('hot_id', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('book_id'), sa.UniqueConstraint('book_db_id') ) op.create_index(op.f('ix_hot_books_book_key'), 'hot_books', ['book_key'], unique=False) # ### end Alembic commands ###
def upgrade(): op.create_table( 'volume_mapping', 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('uuid', sa.String(36), nullable=False), sa.Column('project_id', sa.String(length=255), nullable=True), sa.Column('user_id', sa.String(length=255), nullable=True), sa.Column('volume_id', sa.String(36), nullable=False), sa.Column('volume_provider', sa.String(36), nullable=False), sa.Column('container_uuid', sa.String(36), nullable=False), sa.Column('container_path', sa.String(length=255), nullable=True), sa.Column('connection_info', MediumText(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('uuid', name='uniq_volume0uuid'), )
def upgrade(): op.create_table( 'container', 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('project_id', sa.String(length=255), nullable=True), sa.Column('user_id', sa.String(length=255), nullable=True), sa.Column('uuid', sa.String(length=36), nullable=True), sa.Column('name', sa.String(length=255), nullable=True), sa.Column('image', sa.String(length=255), nullable=True), sa.Column('command', sa.String(length=255), nullable=True), sa.Column('status', sa.String(length=20), nullable=True), sa.Column('environment', zun.db.sqlalchemy.models.JSONEncodedDict(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('uuid', name='uniq_container0uuid') )
def upgrade(): op.create_table( 'zun_service', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('report_count', sa.Integer(), nullable=False), sa.Column('host', sa.String(length=255), nullable=True), sa.Column('binary', sa.String(length=255), nullable=True), sa.Column('disabled', sa.Boolean(), nullable=True), sa.Column('disabled_reason', sa.String(length=255), nullable=True), sa.Column('last_seen_up', sa.DateTime(), nullable=True), sa.Column('forced_down', sa.Boolean(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('host', 'binary', name='uniq_zun_service0host0binary') )
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=64), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=64), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_users_username', 'users', ['username'], unique=True) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=64), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('email', sa.String(length=64), nullable=True), sa.Column('username', sa.String(length=64), nullable=True), sa.Column('password_hash', sa.String(length=128), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.Column('confirmed', sa.Boolean(), nullable=True), sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True) op.drop_table('Products') ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('social_id', sa.String(length=64), nullable=False), sa.Column('nickname', sa.String(length=256), nullable=False), sa.Column('email', sa.String(length=256), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('social_id') ) op.create_table('searches', sa.Column('id', sa.Integer(), nullable=False), sa.Column('search_terms', sa.String(length=64), nullable=False), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('searches', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('search_terms', sa.VARCHAR(length=64), nullable=False), sa.Column('timestamp', sa.DATETIME(), nullable=True), sa.Column('user_id', sa.INTEGER(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('users', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('social_id', sa.VARCHAR(length=64), nullable=False), sa.Column('nickname', sa.VARCHAR(length=64), nullable=False), sa.Column('email', sa.VARCHAR(length=64), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('social_id') ) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('social_id', sa.String(length=64), nullable=False), sa.Column('nickname', sa.String(length=64), nullable=False), sa.Column('email', sa.String(length=64), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('social_id') ) op.create_table('searches', sa.Column('id', sa.Integer(), nullable=False), sa.Column('search_terms', sa.String(length=64), nullable=False), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('statistic_visitor', sa.Column('id', sa.Integer(), nullable=False), sa.Column('last_count', sa.DateTime(), nullable=True), sa.Column('referred', sa.String(length=128), nullable=False), sa.Column('agent', sa.String(length=64), nullable=True), sa.Column('platform', sa.String(length=64), nullable=True), sa.Column('version', sa.String(length=64), nullable=True), sa.Column('ip', sa.String(length=64), nullable=True), sa.Column('hits', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id', 'referred'), sa.UniqueConstraint('id'), sa.UniqueConstraint('referred') ) op.create_index(op.f('ix_statistic_visitor_last_count'), 'statistic_visitor', ['last_count'], unique=False) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('machine_statistic', sa.Column('id', sa.Integer(), nullable=False), sa.Column('type', sa.String(length=64), nullable=True), sa.Column('timestamp', sa.String(length=64), nullable=True), sa.Column('userid', sa.String(length=64), nullable=True), sa.Column('netcode', sa.String(length=64), nullable=True), sa.Column('login_time', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('id') ) op.create_index(op.f('ix_machine_statistic_login_time'), 'machine_statistic', ['login_time'], unique=False) op.alter_column(u'statistic_visitor', 'referred', existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128), nullable=True, existing_server_default=sa.text(u"''")) ### end Alembic commands ###
def upgrade(): op.create_table('user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=255), nullable=False), sa.Column('password', sa.String(), nullable=False), sa.Column('email', sa.String(length=255), nullable=True), sa.Column('confirmed_at', sa.DateTime(), nullable=True), sa.Column('is_active', sa.Boolean(), server_default='0', nullable=False), sa.Column('first_name', sa.String(length=255), server_default='', nullable=False), sa.Column('last_name', sa.String(length=255), server_default='', nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('username') ) op.create_table('bookmark', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user', sa.Integer(), nullable=False), sa.Column('timestamp', sa.DateTime(), nullable=False), sa.Column('url', sa.String(), nullable=False), sa.Column('title', sa.String(), nullable=False), sa.Column('read', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['user'], ['user.id'], ), sa.PrimaryKeyConstraint('id') )
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint(None, 'mailing_list', type_='unique') op.drop_column('mailing_list', 'url') op.create_table('email', sa.Column('id', sa.INTEGER(), server_default=sa.text(u"nextval('email_id_seq'::regclass)"), nullable=False), sa.Column('value', sa.VARCHAR(length=120), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=u'email_pkey'), sa.UniqueConstraint('value', name=u'email_value_key'), postgresql_ignore_search_path=False ) op.create_table('email_mailing_list', sa.Column('mailing_list_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('email_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['email_id'], [u'email.id'], name=u'email_mailing_list_email_id_fkey'), sa.ForeignKeyConstraint(['mailing_list_id'], [u'mailing_list.id'], name=u'email_mailing_list_mailing_list_id_fkey') ) # ### end Alembic commands ###
def upgrade(): """Upgrade the database to a newer revision.""" # commands auto generated by Alembic - please adjust! ### op.create_table('role', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('description', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name')) op.create_table('user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('login', sa.String(length=255), nullable=True), sa.Column('email', sa.String(length=255), nullable=True), sa.Column('password', sa.String(length=255), nullable=True), sa.Column('active', sa.Boolean(), nullable=True), sa.Column('token', sa.String(length=255), nullable=True), sa.Column('token_expires', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('login')) op.create_table('roles_users', sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['role_id'], ['role.id'], ), sa.ForeignKeyConstraint(['user_id'], ['user.id'], )) # end Alembic commands ###
def upgrade(): op.create_table('groups', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=128), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('assoc_group_user', sa.Column('group_id', sa.Integer(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ) ) op.create_table('assoc_post_group', sa.Column('post_id', sa.Integer(), nullable=True), sa.Column('group_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ), sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ) ) op.add_column(u'posts', sa.Column('private', sa.Integer(), nullable=True))
def upgrade(): op.create_table("db_log_item", sa.Column("id", sa.Integer, primary_key = True), sa.Column("message", sa.Text), sa.Column("time", sa.DateTime), sa.Column("level", sa.String(5)), sa.Column("trace", sa.Text), ) op.create_table("db_feed_item", sa.Column("id", sa.Integer, primary_key = True), sa.Column("content", sa.Text), sa.Column("type", sa.String(20)), sa.Column("source", sa.String(125)), sa.Column("time", sa.DateTime), sa.UniqueConstraint('content', 'source', name = 'uk_content_source'), )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('email', sa.Column('user_id', zeus.db.types.guid.GUID(), nullable=False), sa.Column('email', sa.String(length=128), nullable=False), sa.Column('verified', sa.Boolean(), nullable=True), sa.Column('id', zeus.db.types.guid.GUID(), nullable=False), sa.Column('date_created', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint( ['user_id'], ['user.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('user_id', 'email', name='unq_user_email') ) op.create_index(op.f('ix_email_user_id'), 'email', ['user_id'], unique=False) # ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'failurereason', sa.Column('job_id', zeus.db.types.guid.GUID(), nullable=False), sa.Column('reason', zeus.db.types.enum.StrEnum(), nullable=False), sa.Column('repository_id', zeus.db.types.guid.GUID(), nullable=False), sa.Column('id', zeus.db.types.guid.GUID(), nullable=False), sa.Column( 'date_created', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False ), sa.ForeignKeyConstraint(['job_id'], ['job.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('job_id', 'reason', name='unq_failurereason_key') ) op.create_index( op.f('ix_failurereason_repository_id'), 'failurereason', ['repository_id'], unique=False ) # ### end Alembic commands ###
def upgrade(): op.create_table( 'role', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=50)), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name', name='ux_role_name'), ) op.create_table( 'user_roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), sa.ForeignKey('user.id', ondelete='CASCADE')), sa.Column('role_id', sa.Integer(), sa.ForeignKey('role.id', ondelete='CASCADE')), sa.PrimaryKeyConstraint('id'), )
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('issue', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('topic_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('serial', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('published_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('title', sa.VARCHAR(length=128), server_default=sa.text(u"''::character varying"), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['topic_id'], [u'topic.id'], name=u'fk_issue_topic'), sa.ForeignKeyConstraint(['user_id'], [u'user.id'], name=u'fk_issue_user'), sa.PrimaryKeyConstraint('id', name=u'issue_pkey'), sa.UniqueConstraint('topic_id', 'serial', name=u'ux_issue_topic_serial') ) op.add_column('link', sa.Column('issue_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.drop_constraint('fk_link_topic', 'link', type_='foreignkey') op.create_foreign_key(u'fk_link_issue', 'link', 'issue', ['issue_id'], ['id']) op.create_index('ix_issue', 'link', ['issue_id'], unique=False) op.drop_column('link', 'topic_id') ### end Alembic commands ###
def upgrade(): op.create_table( 'ad', sa.Column('id', sa.Integer(), nullable=False), sa.Column('asin', sa.String(20), nullable=False), sa.Column('title', sa.String(128), nullable=False), sa.Column('url', sa.String(1024), nullable=False), sa.Column('description', sa.String(256), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('asin', name='ux_ad_asin'), ) op.create_table( 'link_ad', sa.Column('id', sa.Integer(), nullable=False), sa.Column('issue_id', sa.Integer(), nullable=False), sa.Column('link_id', sa.Integer(), nullable=False), sa.Column('ad_id', sa.Integer(), nullable=False), sa.Column('weight', sa.Numeric(5, 2), nullable=False, server_default='0'), sa.Column('created_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('link_id', 'ad_id', name='ux_link_ad'), ) op.create_index('ix_link_weight', 'link_ad', ['link_id', 'weight'], unique=False) op.create_index('ix_issue_weight', 'link_ad', ['issue_id', 'weight'], unique=False)
def upgrade_development(): ### commands auto generated by Alembic - please adjust! ### op.create_table('users', sa.Column('name', sa.String(length=32), autoincrement=False, nullable=False), sa.Column('id', sa.String(length=32), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('first_seen', sa.DateTime(), nullable=True), sa.Column('last_seen', sa.DateTime(), nullable=True), sa.Column('user_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('name'), sa.UniqueConstraint('name') ) # removed to fix merge conflict #op.add_column('posts', sa.Column('created_at', sa.DateTime(), nullable=True)) # op.drop_index('posts_ibfk_1', table_name='posts') op.add_column('subreddits', sa.Column('created_at', sa.DateTime(), nullable=True)) ### end Alembic commands ###
def upgrade_test(): ### commands auto generated by Alembic - please adjust! ### op.create_table('users', sa.Column('name', sa.String(length=32), autoincrement=False, nullable=False), sa.Column('id', sa.String(length=32), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('first_seen', sa.DateTime(), nullable=True), sa.Column('last_seen', sa.DateTime(), nullable=True), sa.Column('user_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('name'), sa.UniqueConstraint('name') ) # removed to fix merge conflict #op.add_column('posts', sa.Column('created_at', sa.DateTime(), nullable=True)) # op.drop_index('posts_ibfk_1', table_name='posts') op.add_column('subreddits', sa.Column('created_at', sa.DateTime(), nullable=True)) ### end Alembic commands ###
def upgrade_production(): ### commands auto generated by Alembic - please adjust! ### op.create_table('users', sa.Column('name', sa.String(length=32), autoincrement=False, nullable=False), sa.Column('id', sa.String(length=32), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('first_seen', sa.DateTime(), nullable=True), sa.Column('last_seen', sa.DateTime(), nullable=True), sa.Column('user_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('name'), sa.UniqueConstraint('name') ) # removed to fix merge conflict #op.add_column('posts', sa.Column('created_at', sa.DateTime(), nullable=True)) # op.drop_index('posts_ibfk_1', table_name='posts') op.add_column('subreddits', sa.Column('created_at', sa.DateTime(), nullable=True)) ### end Alembic commands ###
def upgrade_development(): ### commands auto generated by Alembic - please adjust! ### op.create_table('archived_comments', sa.Column('id', sa.String(length=256), autoincrement=False, nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('created_utc', sa.DateTime(), nullable=True), sa.Column('subreddit_id', sa.String(length=32), nullable=True), sa.Column('post_id', sa.String(length=32), nullable=True), sa.Column('user_id', sa.String(length=64), nullable=True), sa.Column('comment_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('id') ) op.create_index(op.f('ix_archived_comments_created_at'), 'archived_comments', ['created_at'], unique=False) op.create_index(op.f('ix_archived_comments_post_id'), 'archived_comments', ['post_id'], unique=False) op.create_index(op.f('ix_archived_comments_subreddit_id'), 'archived_comments', ['subreddit_id'], unique=False) op.create_index(op.f('ix_archived_comments_user_id'), 'archived_comments', ['user_id'], unique=False) ### end Alembic commands ###
def upgrade_test(): ### commands auto generated by Alembic - please adjust! ### op.create_table('archived_comments', sa.Column('id', sa.String(length=256), autoincrement=False, nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('created_utc', sa.DateTime(), nullable=True), sa.Column('subreddit_id', sa.String(length=32), nullable=True), sa.Column('post_id', sa.String(length=32), nullable=True), sa.Column('user_id', sa.String(length=64), nullable=True), sa.Column('comment_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('id') ) op.create_index(op.f('ix_archived_comments_created_at'), 'archived_comments', ['created_at'], unique=False) op.create_index(op.f('ix_archived_comments_post_id'), 'archived_comments', ['post_id'], unique=False) op.create_index(op.f('ix_archived_comments_subreddit_id'), 'archived_comments', ['subreddit_id'], unique=False) op.create_index(op.f('ix_archived_comments_user_id'), 'archived_comments', ['user_id'], unique=False) ### end Alembic commands ###
def upgrade_development(): ### commands auto generated by Alembic - please adjust! ### op.create_table('mod_actions', sa.Column('id', sa.String(length=256), autoincrement=False, nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('created_utc', sa.DateTime(), nullable=True), sa.Column('subreddit_id', sa.String(length=32), nullable=True), sa.Column('mod', sa.String(length=64), nullable=True), sa.Column('target_author', sa.String(length=64), nullable=True), sa.Column('action', sa.String(length=256), nullable=True), sa.Column('target_fullname', sa.String(length=256), nullable=True), sa.Column('action_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('id') ) op.create_index(op.f('ix_mod_actions_subreddit_id'), 'mod_actions', ['subreddit_id'], unique=False) op.create_index(op.f('ix_mod_actions_target_author'), 'mod_actions', ['target_author'], unique=False) ### end Alembic commands ###
def upgrade_test(): ### commands auto generated by Alembic - please adjust! ### op.create_table('mod_actions', sa.Column('id', sa.String(length=256), autoincrement=False, nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('created_utc', sa.DateTime(), nullable=True), sa.Column('subreddit_id', sa.String(length=32), nullable=True), sa.Column('mod', sa.String(length=64), nullable=True), sa.Column('target_author', sa.String(length=64), nullable=True), sa.Column('action', sa.String(length=256), nullable=True), sa.Column('target_fullname', sa.String(length=256), nullable=True), sa.Column('action_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('id') ) op.create_index(op.f('ix_mod_actions_subreddit_id'), 'mod_actions', ['subreddit_id'], unique=False) op.create_index(op.f('ix_mod_actions_target_author'), 'mod_actions', ['target_author'], unique=False) ### end Alembic commands ###
def upgrade_production(): ### commands auto generated by Alembic - please adjust! ### op.create_table('mod_actions', sa.Column('id', sa.String(length=256), autoincrement=False, nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('created_utc', sa.DateTime(), nullable=True), sa.Column('subreddit_id', sa.String(length=32), nullable=True), sa.Column('mod', sa.String(length=64), nullable=True), sa.Column('target_author', sa.String(length=64), nullable=True), sa.Column('action', sa.String(length=256), nullable=True), sa.Column('target_fullname', sa.String(length=256), nullable=True), sa.Column('action_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('id') ) op.create_index(op.f('ix_mod_actions_subreddit_id'), 'mod_actions', ['subreddit_id'], unique=False) op.create_index(op.f('ix_mod_actions_target_author'), 'mod_actions', ['target_author'], unique=False) ### end Alembic commands ###
def upgrade_development(): ### commands auto generated by Alembic - please adjust! ### op.create_table('comments', sa.Column('id', sa.String(length=256), autoincrement=False, nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('created_utc', sa.DateTime(), nullable=True), sa.Column('subreddit_id', sa.String(length=32), nullable=True), sa.Column('post_id', sa.String(length=32), nullable=True), sa.Column('user_id', sa.String(length=64), nullable=True), sa.Column('comment_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('id') ) op.create_index(op.f('ix_comments_post_id'), 'comments', ['post_id'], unique=False) op.create_index(op.f('ix_comments_subreddit_id'), 'comments', ['subreddit_id'], unique=False) op.create_index(op.f('ix_comments_user_id'), 'comments', ['user_id'], unique=False) ### end Alembic commands ###
def upgrade_test(): ### commands auto generated by Alembic - please adjust! ### op.create_table('comments', sa.Column('id', sa.String(length=256), autoincrement=False, nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('created_utc', sa.DateTime(), nullable=True), sa.Column('subreddit_id', sa.String(length=32), nullable=True), sa.Column('post_id', sa.String(length=32), nullable=True), sa.Column('user_id', sa.String(length=64), nullable=True), sa.Column('comment_data', mysql.MEDIUMTEXT(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('id') ) op.create_index(op.f('ix_comments_post_id'), 'comments', ['post_id'], unique=False) op.create_index(op.f('ix_comments_subreddit_id'), 'comments', ['subreddit_id'], unique=False) op.create_index(op.f('ix_comments_user_id'), 'comments', ['user_id'], unique=False) ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('tag', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=80), nullable=False), sa.Column('color', ColorType(length=20), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('user_id', 'name') ) op.create_table('contact_tag', sa.Column('contact_id', sa.Integer(), nullable=False), sa.Column('tag_id', sa.Integer(), nullable=False), sa.Column('position', sa.Integer(), nullable=False), sa.Column('note', sa.Text(), nullable=True), sa.ForeignKeyConstraint(['contact_id'], ['contact.id'], ), sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ), sa.PrimaryKeyConstraint('contact_id', 'tag_id') ) # ### end Alembic commands ### op.execute(CreateSequence(Sequence('contact_tag_position')))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=64), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('number', sa.SmallInteger(), nullable=True), sa.Column('username', sa.String(length=64), nullable=True), sa.Column('password', sa.String(length=128), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_users_number'), 'users', ['number'], unique=True) op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=False) # ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('spotify_accesstoken', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('access_token', sa.String(length=256), nullable=True), sa.Column('token_type', sa.String(length=16), nullable=True), sa.Column('scope', sa.String(length=64), nullable=True), sa.Column('expires_in', sa.Integer(), nullable=True), sa.Column('refresh_token', sa.String(length=256), nullable=True), sa.Column('date_created', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), sa.Column('date_updated', sa.DateTime(timezone=True), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('access_token'), sa.UniqueConstraint('refresh_token') ) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('email', sa.String(length=32), nullable=True), sa.Column('password_hash', sa.String(length=128), nullable=True), sa.Column('date_created', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True), sa.Column('date_updated', sa.DateTime(timezone=True), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email') ) op.create_table('github_accesstoken', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('token_type', sa.String(length=16), nullable=True), sa.Column('scope', sa.String(length=64), nullable=True), sa.Column('access_token', sa.String(length=40), nullable=True), sa.Column('date_created', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True), sa.Column('date_updated', sa.DateTime(timezone=True), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('access_token') ) ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('licenses', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=True), sa.Column('description', sa.String(), nullable=True), sa.Column('plain_text', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('users_licenses', sa.Column('user', sa.BigInteger(), nullable=True), sa.Column('license', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['license'], ['licenses.id'], ), sa.ForeignKeyConstraint(['user'], ['users.id'], ) ) op.drop_index('idx_areas_of_interest_centroid', table_name='areas_of_interest') op.drop_index('idx_areas_of_interest_geometry', table_name='areas_of_interest') op.add_column('projects', sa.Column('license_id', sa.Integer(), nullable=True)) op.create_foreign_key('fk_licenses', 'projects', 'licenses', ['license_id'], ['id']) op.drop_index('idx_tasks_geometry', table_name='tasks') # ### end Alembic commands ### # Custom index, not created with reflection op.create_index('idx_username_lower', 'users', [text('lower(username)')])
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=64), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=64), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('template', sa.Column('token_id', sa.Integer(), nullable=False), sa.Column('event', sa.String(length=255), nullable=False), sa.Column('template', sa.String(length=1000), server_default='', nullable=False), sa.PrimaryKeyConstraint('token_id', 'event') ) op.create_table('token', sa.Column('id', sa.Integer(), nullable=False), sa.Column('token', sa.String(length=255), nullable=False), sa.Column('code', sa.String(length=255), nullable=False), sa.Column('secret', sa.String(length=255), server_default='', nullable=False), sa.Column('description', sa.String(length=255), server_default='', nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) ### end Alembic commands ###
def upgrade(): op.create_table('base_string', sa.Column('id', postgresql.UUID(as_uuid=True), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('resource_pk', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('base_string', sa.Text(), nullable=False), sa.Column('comment', sa.Text(), nullable=False), sa.Column('context', sa.Text(), nullable=False), sa.ForeignKeyConstraint(['resource_pk'], ['resource.id'], ), sa.PrimaryKeyConstraint('id') ) op.drop_table('translated_string') op.create_table('translated_string', sa.Column('id', sa.Integer(), nullable=False, autoincrement=True), sa.Column('base_string_pk', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('language_pk', sa.Integer, nullable=False), sa.Column('translation', sa.Text(), nullable=False), sa.Column('translator_comment', sa.Text(), nullable=False), sa.ForeignKeyConstraint(['base_string_pk'], ['base_string.id'], ), sa.ForeignKeyConstraint(['language_pk'], ['language.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('base_string_pk', 'language_pk', name='base_string_language_uc'), )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.Integer(), nullable=True), sa.Column('updated_at', sa.Integer(), nullable=True), sa.Column('last_seen_at', sa.Integer(), nullable=True), sa.Column('nickname', sa.String(length=32), nullable=False), sa.Column('password_hash', sa.String(length=256), nullable=False), sa.Column('token', sa.String(length=64), nullable=True), sa.Column('online', sa.Boolean(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('nickname'), sa.UniqueConstraint('token') ) # ### end Alembic commands ###
def upgrade(): table_prefix = context.config.get_main_option('table_prefix') op.create_table( table_prefix + 'repos', sa.Column('id', sa.Integer(), nullable=False, primary_key=True), sa.Column('repo_name', sa.Unicode(100), nullable=False), sa.Column('env_id', sa.Integer(), nullable=False), sa.Column('git_url', sa.String(255), server_default='', nullable=False), sa.Column('ref', sa.String(255), server_default='', nullable=False), sa.Column('user_key', sa.String(255), server_default='', nullable=False), sa.UniqueConstraint('env_id', name='_env_id_unique'))
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('identity', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('provider', sa.String(length=255), nullable=False), sa.Column('provider_user_id', sa.String(length=255), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('last_used_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('provider', 'provider_user_id', name='uniq_provider_user_id') ) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=255), nullable=False), sa.Column('email', sa.String(length=255), nullable=False), sa.Column('password', sqlalchemy_utils.types.password.PasswordType(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('password_changed_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('username') ) op.create_table('session', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('token', sa.String(length=255), nullable=True), sa.Column('user_agent', sa.String(length=255), nullable=True), sa.Column('ip_address', sa.String(length=255), nullable=True), sa.Column('platform', sa.String(length=255), nullable=True), sa.Column('browser', sa.String(length=255), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('last_active_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('category', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=100), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('email', sa.String(length=200), nullable=False), sa.Column('name', sa.String(length=100), nullable=True), sa.Column('token', sa.Text(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email') ) op.create_table('item', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=100), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('category_id', sa.Integer(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['category_id'], ['category.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('title') ) # ### end Alembic commands ###