我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用alembic.op.create_index()。
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('topic_suggestion', 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('title', sa.String(), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('is_recorded', sa.Boolean(), nullable=False), sa.Column('podcast_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_topic_suggestion_id'), 'topic_suggestion', ['id'], unique=False) op.create_index(op.f('ix_topic_suggestion_title'), 'topic_suggestion', ['title'], unique=False) op.create_index(op.f('ix_episode_id'), 'episode', ['id'], unique=False) op.create_index(op.f('ix_podcast_id'), 'podcast', ['id'], unique=False) op.create_index(op.f('ix_popular_term_id'), 'popular_term', ['id'], unique=False) op.create_index(op.f('ix_tag_id'), 'tag', ['id'], unique=False) ### end Alembic commands ###
def upgrade(): op.execute(sa.schema.CreateSequence(sa.Sequence('pod_states_id_seq'))) op.add_column('pod_states', sa.Column('id', sa.Integer(), nullable=False, server_default=sa.text("nextval('pod_states_id_seq'::regclass)"))) op.execute("ALTER TABLE pod_states DROP CONSTRAINT pod_states_pkey, " "ADD CONSTRAINT pod_states_pkey PRIMARY KEY (id);") op.add_column('container_states', sa.Column('exit_code', sa.Integer(), nullable=True)) op.add_column('container_states', sa.Column('pod_state_id', sa.Integer(), nullable=True)) op.add_column('container_states', sa.Column('reason', sa.Text(), nullable=True)) op.create_index('ix_pod_id_start_time', 'pod_states', ['pod_id', 'start_time'], unique=True) op.create_foreign_key('container_states_pod_state_id_fkey', 'container_states', 'pod_states', ['pod_state_id'], ['id']) upgrade_data() op.alter_column('container_states', 'pod_state_id', existing_type=sa.INTEGER(), nullable=False) op.drop_constraint(u'container_states_pod_id_fkey', 'container_states', type_='foreignkey') op.drop_column('container_states', 'pod_id')
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('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('sprints', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_name', sa.Unicode(), nullable=True), sa.Column('creation_date', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table('retrospective_items', sa.Column('id', sa.Integer(), nullable=False), sa.Column('sprint_id', sa.Integer(), nullable=False), sa.Column('category', sa.Unicode(), nullable=True), sa.Column('text', sa.Unicode(), nullable=True), sa.Column('user_name', sa.Unicode(), nullable=True), sa.Column('creation_date', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_retrospective_items'), 'retrospective_items', ['sprint_id', 'category'], unique=False)
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('comments', sa.Column('id', sa.Integer(), nullable=False), sa.Column('body', sa.Text(), nullable=True), sa.Column('body_html', sa.Text(), nullable=True), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.Column('disabled', sa.Boolean(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('post_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index('ix_comments_timestamp', 'comments', ['timestamp'], unique=False) ### 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('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(): op.alter_column('kubes', 'name', existing_type=sa.VARCHAR(length=64), nullable=False) op.create_index('one_default', 'kubes', ['is_default'], unique=True, postgresql_where=sa.text(u'kubes.is_default IS true')) op.drop_constraint(u'kubes_is_default_key', 'kubes', type_='unique') op.alter_column('packages', 'name', existing_type=sa.VARCHAR(length=64), nullable=False) op.alter_column('packages', 'prefix', existing_type=sa.VARCHAR(), nullable=False) op.alter_column('packages', 'suffix', existing_type=sa.VARCHAR(), nullable=False) session = Session(bind=op.get_bind()) session.query(PackageKube).filter(sa.or_( PackageKube.package_id.is_(None), PackageKube.kube_id.is_(None), )).delete() session.commit() op.alter_column('package_kube', 'kube_id', existing_type=sa.INTEGER(), nullable=False) op.alter_column('package_kube', 'package_id', existing_type=sa.INTEGER(), nullable=False)
def upgrade(): migration_context = context.get_context() if migration_context.dialect.name == 'sqlite': id_type = sa.Integer else: id_type = sa.BigInteger op.create_table('coverages', sa.Column('id', id_type, autoincrement=True, primary_key=True), sa.Column('project_name', sa.String(256), nullable=False), sa.Column('coverage_rate', sa.Float()), sa.Column('report_time', sa.DateTime()), sa.Column('report_time_microsecond', sa.Integer(), default=0), mysql_engine='InnoDB') op.create_index('ix_project_name', 'coverages', ['project_name'])
def upgrade(): migration_context = context.get_context() if migration_context.dialect.name == 'sqlite': id_type = sa.Integer else: id_type = sa.BigInteger op.create_table('files', sa.Column('id', id_type, autoincrement=True, primary_key=True), sa.Column('coverage_id', id_type, nullable=False), sa.Column('filename', sa.String(256), nullable=False), sa.Column('line_rate', sa.Float()), mysql_engine='InnoDB') op.create_index('ix_class_coverage_id', 'files', ['coverage_id']) op.create_index('ix_filename', 'files', ['filename'])
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('user', sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('username', sa.Unicode(length=255), nullable=False), sa.Column('password', sqlalchemy_utils.types.password.PasswordType(), nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('is_superuser', sa.Boolean(), server_default='FALSE', nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True) op.create_table('user_problem', sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('problem_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('user_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.ForeignKeyConstraint(['problem_id'], ['problem.id'], ), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_user_problem_user_id'), 'user_problem', ['user_id'], unique=False) # ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('comments', sa.Column('id', sa.Integer(), nullable=False), sa.Column('body', sa.Text(), nullable=True), sa.Column('body_html', sa.Text(), nullable=True), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.Column('disabled', sa.Boolean(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('post_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], 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(): ### 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(): ### commands auto generated by Alembic - please adjust! ### op.create_table('scoreboard', sa.Column('user_id', sa.BigInteger(), nullable=False), sa.Column('ladder_name', sa.String(), nullable=False), sa.Column('mmr', sa.Integer(), nullable=False), sa.Column('matches', sa.Integer(), server_default='0', nullable=False), sa.Column('win', sa.Integer(), server_default='0', nullable=False), sa.Column('loss', sa.Integer(), server_default='0', nullable=False), sa.Column('dodge', sa.Integer(), server_default='0', nullable=False), sa.Column('leave', sa.Integer(), server_default='0', nullable=False), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('user_id', 'ladder_name') ) op.create_index(op.f('ix_scoreboard_mmr'), 'scoreboard', ['mmr'], unique=False) op.add_column('match', sa.Column('radiant_win', sa.Boolean(), nullable=True)) op.add_column('match', sa.Column('section', sa.String(), server_default='high', nullable=False)) op.add_column('player_in_match', sa.Column('is_dodge', sa.Boolean(), server_default='false', nullable=False)) op.add_column('user', sa.Column('section', sa.String(), nullable=True)) ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('law', sa.Column('search_vector', sqlalchemy_utils.types.ts_vector.TSVectorType(), nullable=True)) op.create_index('ix_law_search_vector', 'law', ['search_vector'], unique=False, postgresql_using='gin') op.add_column('page', sa.Column('search_vector', sqlalchemy_utils.types.ts_vector.TSVectorType(), nullable=True)) op.create_index('ix_page_search_vector', 'page', ['search_vector'], unique=False, postgresql_using='gin') op.add_column('post', sa.Column('search_vector', sqlalchemy_utils.types.ts_vector.TSVectorType(), nullable=True)) op.create_index('ix_post_search_vector', 'post', ['search_vector'], unique=False, postgresql_using='gin') op.add_column('proposal', sa.Column('search_vector', sqlalchemy_utils.types.ts_vector.TSVectorType(), nullable=True)) op.create_index('ix_proposal_search_vector', 'proposal', ['search_vector'], unique=False, postgresql_using='gin') op.add_column('topic', sa.Column('search_vector', sqlalchemy_utils.types.ts_vector.TSVectorType(), nullable=True)) op.create_index('ix_topic_search_vector', 'topic', ['search_vector'], unique=False, postgresql_using='gin') op.add_column('user', sa.Column('search_vector', sqlalchemy_utils.types.ts_vector.TSVectorType(), nullable=True)) op.create_index('ix_user_search_vector', 'user', ['search_vector'], unique=False, postgresql_using='gin') # ### manually inserted searchable sync ### conn = op.get_bind() sync_trigger(conn, 'law', 'search_vector', ['content']) sync_trigger(conn, 'page', 'search_vector', ['title', 'content']) sync_trigger(conn, 'post', 'search_vector', ['content']) sync_trigger(conn, 'proposal', 'search_vector', ['description']) sync_trigger(conn, 'topic', 'search_vector', ['name', 'description']) sync_trigger(conn, 'user', 'search_vector', ['username']) # ### end Alembic commands ###
def upgrade(): """Upgrade the database to a newer revision.""" # commands auto generated by Alembic - please adjust! ### op.create_table('analysis_requests', sa.Column('ecosystem', sa.Integer(), nullable=True), sa.Column('package', sa.String(length=255), nullable=True), sa.Column('version', sa.String(length=255), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('job_id', sa.String(length=255), nullable=True), sa.Column('submitted_at', sa.DateTime(), nullable=True), sa.Column('fulfilled_at', sa.DateTime(), nullable=True), sa.Column('analysis_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['analysis_id'], ['analyses.id'], ), sa.PrimaryKeyConstraint('id')) op.create_index('epv_index', 'analysis_requests', ['ecosystem', 'package', 'version'], unique=True, postgresql_where=sa.text('fulfilled_at IS NULL')) # end Alembic commands ###
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(): ### commands auto generated by Alembic - please adjust! ### op.create_table('book', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=255), nullable=False), sa.Column('posted_on', sa.Date(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=64), nullable=True), sa.Column('password_hash', sa.String(length=128), nullable=True), sa.Column('email', sa.String(length=64), nullable=True), 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) ### end Alembic commands ###
def change_task(self): # Task in elixir did not generate a row_type for use as discriminator self.schedule('alter', op.add_column, 'task', Column('row_type', String(40))) # Task in elixir's queue_id was NULLABLE, but should not be (Tasks HAVE to be in a Queue now) self.schedule('alter', op.alter_column, 'task', 'queue_id', nullable=True) # Rename of relationship foreign key Task.reserved_by_id -> reserved_by_party_id old_name = 'reserved_by_id' new_name = 'reserved_by_party_id' self.schedule('drop_fk', op.drop_constraint, '%s_%s_fk' % ('task', old_name), 'task') self.schedule('alter', op.alter_column, 'task', old_name, new_column_name=new_name) self.schedule('create_fk', op.create_foreign_key, fk_name('task', new_name, 'party'), 'task', 'party', [new_name], ['id']) self.schedule('drop_pk', op.drop_index, ix_name('task', 'reserved_by_id')) self.schedule('indexes', op.create_index, ix_name('task','reserved_by_party_id'), 'task', ['reserved_by_party_id'])
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('shared_notes', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_date', sa.DateTime(), nullable=True), sa.Column('updated_date', sa.DateTime(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('note_id', sa.Integer(), nullable=True), sa.Column('recipient_email', sa.String(length=254), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.ForeignKeyConstraint(['note_id'], ['notes.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_shared_notes_created_date'), 'shared_notes', ['created_date'], unique=False) op.create_index(op.f('ix_shared_notes_updated_date'), 'shared_notes', ['updated_date'], unique=False) op.add_column('users', sa.Column('last_login_date', sa.DateTime(), nullable=True)) ### end Alembic commands ###
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('comments', sa.Column('id', sa.Integer(), nullable=False), sa.Column('body', sa.Text(), nullable=True), sa.Column('body_html', sa.Text(), nullable=True), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.Column('disabled', sa.Boolean(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('post_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False) ### end Alembic commands ###
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('event_hooks', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=256), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('experiment_id', sa.Integer(), nullable=True), sa.Column('is_active', sa.Boolean(), nullable=True), sa.Column('call_when', sa.Integer(), nullable=True), sa.Column('caller_controller', sa.String(length=256), nullable=False), sa.Column('caller_method', sa.String(length=256), nullable=False), sa.Column('callee_module', sa.String(length=256), nullable=False), sa.Column('callee_controller', sa.String(length=256), nullable=False), sa.Column('callee_method', sa.String(length=256), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_event_hooks_experiment_id'), 'event_hooks', ['experiment_id'], unique=False) op.create_index(op.f('ix_event_hooks_name'), 'event_hooks', ['name'], unique=False) # ### end Alembic commands ###
def upgrade_test(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('event_hooks', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=256), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('experiment_id', sa.Integer(), nullable=True), sa.Column('is_active', sa.Boolean(), nullable=True), sa.Column('call_when', sa.Integer(), nullable=True), sa.Column('caller_controller', sa.String(length=256), nullable=False), sa.Column('caller_method', sa.String(length=256), nullable=False), sa.Column('callee_module', sa.String(length=256), nullable=False), sa.Column('callee_controller', sa.String(length=256), nullable=False), sa.Column('callee_method', sa.String(length=256), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_event_hooks_experiment_id'), 'event_hooks', ['experiment_id'], unique=False) op.create_index(op.f('ix_event_hooks_name'), 'event_hooks', ['name'], unique=False) # ### 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_production(): ### 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('posts', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(), nullable=True), sa.Column('body', sa.String(), nullable=True), sa.Column('body_html', sa.String(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_posts_created'), 'posts', ['created'], unique=False) op.create_table('comment', sa.Column('id', sa.Integer(), nullable=False), sa.Column('body', sa.String(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('post_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_comment_created'), 'comment', ['created'], unique=False) ### 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('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 batch_create_index(cls, operations, index_name, columns, **kw): """Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_index` """ op = cls( index_name, operations.impl.table_name, columns, schema=operations.impl.schema, **kw ) return operations.invoke(op)
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('bit_performance_report', sa.Column('id', sa.Integer(), nullable=False), sa.Column('date', sa.DateTime(), nullable=True), sa.Column('year', sa.Integer(), nullable=True), sa.Column('month', sa.Integer(), nullable=True), sa.Column('day', sa.Integer(), nullable=True), sa.Column('name', sa.String(length=250), nullable=True), sa.Column('campaign_source', sa.String(length=250), nullable=True), sa.Column('campaign_name', sa.String(length=250), nullable=True), sa.Column('campaign_id', sa.String(length=250), nullable=True), sa.Column('clicks', sa.Integer(), nullable=True), sa.Column('clicks_unique', sa.Integer(), nullable=True), sa.Column('impressions', sa.Integer(), nullable=True), sa.Column('conversions', sa.Integer(), nullable=True), sa.Column('cost', sa.Numeric(precision=17, scale=5), nullable=True), sa.Column('breakdowns', postgresql.HSTORE(text_type=sa.Text()), nullable=True), sa.Column('measurements', postgresql.HSTORE(text_type=sa.Text()), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_bit_performance_report_breakdowns'), 'bit_performance_report', ['breakdowns'], unique=False) op.create_index(op.f('ix_bit_performance_report_campaign_id'), 'bit_performance_report', ['campaign_id'], unique=False) op.create_index(op.f('ix_bit_performance_report_campaign_name'), 'bit_performance_report', ['campaign_name'], unique=False) op.create_index(op.f('ix_bit_performance_report_campaign_source'), 'bit_performance_report', ['campaign_source'], unique=False) op.create_index(op.f('ix_bit_performance_report_date'), 'bit_performance_report', ['date'], unique=False) op.create_index(op.f('ix_bit_performance_report_day'), 'bit_performance_report', ['day'], unique=False) op.create_index(op.f('ix_bit_performance_report_month'), 'bit_performance_report', ['month'], unique=False) op.create_index(op.f('ix_bit_performance_report_name'), 'bit_performance_report', ['name'], unique=False) op.create_index(op.f('ix_bit_performance_report_year'), 'bit_performance_report', ['year'], unique=False) # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('bit_facebook_daily_ad_insights', sa.Column('campaign_id', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.add_column('bit_facebook_daily_ad_insights', sa.Column('native_id', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.create_index('ix_bit_facebook_daily_ad_insights_native_id', 'bit_facebook_daily_ad_insights', ['native_id'], unique=True) op.drop_column('bit_facebook_daily_ad_insights', 'date_start') # ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('bit_adwords_campaign_performance_report', sa.Column('id', sa.Integer(), nullable=False), sa.Column('campaign_name', sa.String(length=255), nullable=True), sa.Column('cost', sa.Numeric(), nullable=True), sa.Column('clicks', sa.Integer(), nullable=True), sa.Column('impression_device', sa.String(length=255), nullable=True), sa.Column('impressions', sa.Integer(), nullable=True), sa.Column('conversions', sa.Integer(), nullable=True), sa.Column('date', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_bit_adwords_campaign_performance_report_impression_device'), 'bit_adwords_campaign_performance_report', ['impression_device'], unique=False) # ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('bit_data_source_info', sa.Column('id', sa.Integer(), nullable=False), sa.Column('source', sa.String(length=255), nullable=True), sa.Column('name', sa.String(length=255), nullable=True), sa.Column('sync_time', sa.String(length=255), nullable=True), sa.Column('last_id', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_bit_data_source_info_last_id'), 'bit_data_source_info', ['last_id'], unique=False) op.create_index(op.f('ix_bit_data_source_info_name'), 'bit_data_source_info', ['name'], unique=False) op.create_index(op.f('ix_bit_data_source_info_source'), 'bit_data_source_info', ['source'], unique=False) op.create_index(op.f('ix_bit_data_source_info_sync_time'), 'bit_data_source_info', ['sync_time'], unique=False) # ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('bit_facebook_daily_ad_insights', sa.Column('native_id', sa.String(length=255), nullable=True)) op.create_index(op.f('ix_bit_facebook_daily_ad_insights_native_id'), 'bit_facebook_daily_ad_insights', ['native_id'], unique=True) # ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('bit_facebook_ad_campaigns', sa.Column('account_id', sa.String(length=255), nullable=True)) op.create_index(op.f('ix_bit_facebook_ad_campaigns_account_id'), 'bit_facebook_ad_campaigns', ['account_id'], unique=True) op.add_column('bit_facebook_ad_sets', sa.Column('account_id', sa.String(length=255), nullable=True)) op.add_column('bit_facebook_ad_sets', sa.Column('campaign_id', sa.String(length=255), nullable=True)) op.create_index(op.f('ix_bit_facebook_ad_sets_account_id'), 'bit_facebook_ad_sets', ['account_id'], unique=True) op.create_index(op.f('ix_bit_facebook_ad_sets_campaign_id'), 'bit_facebook_ad_sets', ['campaign_id'], unique=True) # ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('bit_facebook_ad', sa.Column('id', sa.Integer(), nullable=False), sa.Column('ad_set_id', sa.Integer(), nullable=True), sa.Column('native_id', sa.String(length=255), nullable=True), sa.Column('account_id', sa.String(length=255), nullable=True), sa.Column('campaign_id', sa.String(length=255), nullable=True), sa.Column('adset_id', sa.String(length=255), nullable=True), sa.Column('name', sa.String(length=255), nullable=True), sa.Column('bid_amount', sa.Integer(), nullable=True), sa.Column('bid_info', sa.String(length=255), nullable=True), sa.Column('bid_type', sa.String(length=255), nullable=True), sa.Column('configured_status', sa.String(length=255), nullable=True), sa.Column('effective_status', sa.String(length=255), nullable=True), sa.Column('status', sa.String(length=255), nullable=True), sa.Column('created_time', sa.DateTime(), nullable=True), sa.Column('updated_time', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['ad_set_id'], ['bit_facebook_ad_sets.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_bit_facebook_ad_native_id'), 'bit_facebook_ad', ['native_id'], unique=True) op.add_column(u'bit_facebook_ad_campaigns', sa.Column('ad_account_id', sa.Integer(), nullable=True)) op.drop_index('ix_bit_facebook_ad_campaigns_account_id', table_name='bit_facebook_ad_campaigns') op.create_foreign_key(None, 'bit_facebook_ad_campaigns', 'bit_facebook_ad_account', ['ad_account_id'], ['id']) op.add_column(u'bit_facebook_ad_sets', sa.Column('ad_campaign_id', sa.Integer(), nullable=True)) op.drop_index('ix_bit_facebook_ad_sets_account_id', table_name='bit_facebook_ad_sets') op.drop_index('ix_bit_facebook_ad_sets_campaign_id', table_name='bit_facebook_ad_sets') op.create_foreign_key(None, 'bit_facebook_ad_sets', 'bit_facebook_ad_campaigns', ['ad_campaign_id'], ['id']) # ### end Alembic commands ###