我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sqlalchemy.INTEGER。
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 downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('privatemessages', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('user_id', sa.INTEGER(), nullable=False), sa.Column('from_user_id', sa.INTEGER(), nullable=True), sa.Column('to_user_id', sa.INTEGER(), nullable=True), sa.Column('subject', sa.VARCHAR(length=255), nullable=True), sa.Column('message', sa.TEXT(), nullable=True), sa.Column('date_created', sa.DATETIME(), nullable=True), sa.Column('trash', sa.BOOLEAN(), nullable=False), sa.Column('draft', sa.BOOLEAN(), nullable=False), sa.Column('unread', sa.BOOLEAN(), nullable=False), sa.ForeignKeyConstraint(['from_user_id'], [u'users.id'], ), sa.ForeignKeyConstraint(['to_user_id'], [u'users.id'], ), sa.ForeignKeyConstraint(['user_id'], [u'users.id'], ), sa.PrimaryKeyConstraint('id') ) op.drop_table('messages') op.drop_table('conversations') ### 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 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 downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('housing_evals', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('uid', sa.VARCHAR(length=32), nullable=False), sa.Column('social_attended', sa.TEXT(), nullable=False), sa.Column('social_hosted', sa.TEXT(), nullable=False), sa.Column('technical_attended', sa.TEXT(), nullable=False), sa.Column('technical_hosted', sa.TEXT(), nullable=False), sa.Column('projects', sa.TEXT(), nullable=False), sa.Column('comments', sa.TEXT(), nullable=False), sa.Column('points', sa.INTEGER(), nullable=False), sa.Column('active', sa.BOOLEAN(), nullable=False), sa.Column('date_created', sa.DATE(), nullable=False), sa.PrimaryKeyConstraint('id') ) ### end Alembic commands ###
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(): # ### commands auto generated by Alembic - please adjust! ### op.alter_column('channels', 'owner_id', existing_type=sa.VARCHAR(), nullable=False) op.alter_column('disabled_channels', 'channel_id', existing_type=sa.VARCHAR(), nullable=False) op.alter_column('disabled_channels', 'last_vk_post_id', existing_type=sa.INTEGER(), nullable=False) op.alter_column('disabled_channels', 'owner_id', existing_type=sa.VARCHAR(), nullable=False) op.alter_column('disabled_channels', 'vk_group_id', existing_type=sa.VARCHAR(), nullable=False) # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.alter_column('disabled_channels', 'vk_group_id', existing_type=sa.VARCHAR(), nullable=True) op.alter_column('disabled_channels', 'owner_id', existing_type=sa.VARCHAR(), nullable=True) op.alter_column('disabled_channels', 'last_vk_post_id', existing_type=sa.INTEGER(), nullable=True) op.alter_column('disabled_channels', 'channel_id', existing_type=sa.VARCHAR(), nullable=True) op.alter_column('channels', 'owner_id', existing_type=sa.VARCHAR(), nullable=True) # ### end Alembic commands ###
def downgrade(): """Downgrade the database to an older revision.""" # commands auto generated by Alembic - please adjust! ### op.drop_column('batches_versions', 'id') op.create_table('analysis_requests', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('job_id', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('submitted_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('fulfilled_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('analysis_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('version_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('parent_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['analysis_id'], ['analyses.id'], name='analysis_requests_analysis_id_fkey'), sa.ForeignKeyConstraint(['version_id'], ['versions.id'], name='analysis_requests_version_id_fkey'), sa.PrimaryKeyConstraint('id', name='analysis_requests_pkey')) # end Alembic commands ###
def downgrade(): """Downgrade the database to an older revision.""" # # commands auto generated by Alembic - please adjust! ### op.create_table('batches_versions', sa.Column('version_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('batch_token', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['batch_token'], ['batch.token'], name='batches_versions_batch_token_fkey'), sa.ForeignKeyConstraint(['version_id'], ['versions.id'], name='batches_versions_version_id_fkey')) op.create_table('batch', sa.Column('token', sa.INTEGER(), nullable=False), sa.Column('started_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('token', name='batch_pkey')) # # 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(): ### commands auto generated by Alembic - please adjust! ### op.create_table('roles', sa.Column('id', sa.INTEGER()), sa.Column('name', sa.VARCHAR()), sa.PrimaryKeyConstraint('id') ) op.create_table('users', sa.Column('id', sa.INTEGER()), sa.Column('name', sa.VARCHAR()), sa.Column('password', sa.VARCHAR()), sa.Column('role_id', sa.INTEGER()), sa.ForeignKeyConstraint(['role_id'], [u'roles.id'], ), sa.PrimaryKeyConstraint('id') ) ### end Alembic commands ###
def downgrade(): """Downgrade the database to an older revision.""" # ### commands auto generated by Alembic - please adjust! ### op.drop_column('batches_versions', 'id') op.create_table('analysis_requests', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('job_id', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('submitted_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('fulfilled_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('analysis_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('version_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('parent_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['analysis_id'], ['analyses.id'], name='analysis_requests_analysis_id_fkey'), sa.ForeignKeyConstraint(['version_id'], ['versions.id'], name='analysis_requests_version_id_fkey'), sa.PrimaryKeyConstraint('id', name='analysis_requests_pkey')) # ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('privatemessages', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('user_id', sa.INTEGER(), nullable=False), sa.Column('from_user_id', sa.INTEGER(), nullable=True), sa.Column('to_user_id', sa.INTEGER(), nullable=True), sa.Column('subject', sa.VARCHAR(length=255), nullable=True), sa.Column('message', sa.TEXT(), nullable=True), sa.Column('date_created', sa.DateTime(), nullable=True), sa.Column('trash', sa.BOOLEAN(), nullable=False), sa.Column('draft', sa.BOOLEAN(), nullable=False), sa.Column('unread', sa.BOOLEAN(), nullable=False), sa.ForeignKeyConstraint(['from_user_id'], [u'users.id'], ), sa.ForeignKeyConstraint(['to_user_id'], [u'users.id'], ), sa.ForeignKeyConstraint(['user_id'], [u'users.id'], ), sa.PrimaryKeyConstraint('id') ) op.drop_table('messages') op.drop_table('conversations') ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('programs_of_study', sa.Column('level', sa.VARCHAR(), autoincrement=False, nullable=True)) op.drop_column('programs_of_study', 'post_type') op.add_column('courses', sa.Column('code', sa.VARCHAR(), autoincrement=False, nullable=True)) op.create_table('users', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('fb_id', sa.VARCHAR(length=18), autoincrement=False, nullable=True), sa.Column('fb_first_name', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('fb_last_name', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('faculty', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('college_eng_type', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('year', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('commuter', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=u'users_pkey'), sa.UniqueConstraint('fb_id', name=u'users_fb_id_key') ) ### end Alembic commands ###
def downgrade(): op.drop_table('inpatientlocation') op.drop_table('inpatientadmission') op.create_table('inpatientepisode', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('datetime_of_admission', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), sa.Column('datetime_of_discharge', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('visit_number', sa.VARCHAR(length=250), autoincrement=False, nullable=False), sa.Column('admission_diagnosis', sa.VARCHAR(length=250), autoincrement=False, nullable=True), sa.Column('gloss_reference_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['gloss_reference_id'], [u'glossolaliareference.id'], name=u'inpatientepisode_gloss_reference_id_fkey'), sa.PrimaryKeyConstraint('id', name=u'inpatientepisode_pkey') ) op.create_table('inpatientlocation', sa.Column('id', sa.Integer(), nullable=False), sa.Column('updated', sa.DateTime(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('inpatient_episode_id', sa.Integer(), nullable=True), sa.Column('datetime_of_transfer', sa.DateTime(), nullable=True), sa.Column('ward_code', sa.String(length=250), nullable=True), sa.Column('room_code', sa.String(length=250), nullable=True), sa.Column('bed_code', sa.String(length=250), nullable=True), sa.ForeignKeyConstraint(['inpatient_episode_id'], ['inpatientepisode.id'], ), sa.PrimaryKeyConstraint('id') ) ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('bit_appsflyer_connector', sa.Column('connector_id', sa.INTEGER(), autoincrement=False, nullable=False)) op.drop_constraint(None, 'bit_appsflyer_connector', type_='foreignkey') op.create_foreign_key(u'bit_appsflyer_connector_connector_id_fkey', 'bit_appsflyer_connector', 'bit_connectors', ['connector_id'], ['id']) op.drop_column('bit_appsflyer_connector', 'id') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('bit_facebook_daily_ad_insights', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('ad_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('buying_type', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('unique_clicks', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('age', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('gender', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('date_stop', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('date_start', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['ad_id'], [u'bit_facebook_ad.id'], name=u'bit_facebook_daily_ad_insights_ad_id_fkey'), sa.PrimaryKeyConstraint('id', name=u'bit_facebook_daily_ad_insights_pkey') ) # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('bit_connectors_appsflyer', sa.Column('app_id', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('api_token', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('url_pat', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('connector_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['connector_id'], [u'bit_connectors.id'], name=u'bit_connectors_appsflyer_connector_id_fkey') ) op.drop_table('bit_appsflyer_connector') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('bit_connectors_appsflyer', sa.Column('id', sa.INTEGER(), nullable=False)) op.drop_constraint(None, 'bit_connectors_appsflyer', type_='foreignkey') op.drop_column('bit_connectors_appsflyer', 'connector_id') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('bit_facebook_connector', sa.Column('connector_id', sa.INTEGER(), autoincrement=False, nullable=False)) op.drop_constraint(None, 'bit_facebook_connector', type_='foreignkey') op.create_foreign_key(u'bit_facebook_connector_connector_id_fkey', 'bit_facebook_connector', 'bit_connectors', ['connector_id'], ['id']) op.drop_column('bit_facebook_connector', 'id') op.drop_constraint(None, 'bit_facebook_ad_account', type_='foreignkey') op.create_foreign_key(u'bit_facebook_ad_account_connector_id_fkey', 'bit_facebook_ad_account', 'bit_facebook_connector', ['connector_id'], ['connector_id']) op.drop_constraint(None, 'bit_adwords_google_drive_storage', type_='foreignkey') op.create_foreign_key(u'bit_adwords_google_drive_storage_connector_id_fkey', 'bit_adwords_google_drive_storage', 'bit_adwords_connector', ['connector_id'], ['connector_id']) op.add_column('bit_adwords_connector', sa.Column('connector_id', sa.INTEGER(), autoincrement=False, nullable=False)) op.drop_constraint(None, 'bit_adwords_connector', type_='foreignkey') op.create_foreign_key(u'bit_adwords_connector_connector_id_fkey', 'bit_adwords_connector', 'bit_connectors', ['connector_id'], ['id']) op.drop_column('bit_adwords_connector', 'id') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('bit_facebook_ad_campaigns', sa.Column('account_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.create_foreign_key(u'bit_facebook_ad_campaigns_account_id_fkey', 'bit_facebook_ad_campaigns', 'bit_facebook_ad_account', ['account_id'], ['id']) # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('bit_chiter_connector', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('app_id', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('api_token', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('url_pat', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['id'], [u'bit_connectors.id'], name=u'bit_chiter_connector_id_fkey'), sa.PrimaryKeyConstraint('id', name=u'bit_chiter_connector_pkey') ) # ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('topic_suggestion', sa.Column('podcast_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.create_foreign_key('topic_suggestion_podcast_id_fkey', 'topic_suggestion', 'podcast', ['podcast_id'], ['id']) ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('role', sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('role_id_seq'::regclass)"), nullable=False), sa.Column('name', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('description', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name='role_pkey'), sa.UniqueConstraint('name', name='role_name_key'), postgresql_ignore_search_path=False ) op.create_table('user', sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('user_id_seq'::regclass)"), nullable=False), sa.Column('email', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('active', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('confirmed_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('password', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name='user_pkey'), sa.UniqueConstraint('email', name='user_email_key'), postgresql_ignore_search_path=False ) op.create_table('roles_users', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('role_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['role_id'], ['role.id'], name='roles_users_role_id_fkey'), sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='roles_users_user_id_fkey') ) ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('kubes', sa.Column('total_traffic', sa.INTEGER(), autoincrement=False, server_default='0', nullable=False)) conn = op.get_bind() conn.execute("UPDATE kubes SET total_traffic=included_traffic") op.drop_column('kubes', 'included_traffic') ### end Alembic commands ###
def upgrade(): op.alter_column('pd_states', 'user_id', existing_type=sa.INTEGER(), nullable=True)
def downgrade(): op.alter_column('pd_states', 'user_id', existing_type=sa.INTEGER(), nullable=False)
def upgrade(): session = Session(bind=op.get_bind()) default_package_id = session.query(Package.id).filter(Package.is_default).scalar() for user in session.query(User).filter(User.package_id.is_(None)): user.package_id = default_package_id session.commit() op.alter_column('users', 'package_id', existing_type=sa.INTEGER(), nullable=False)
def downgrade(): op.alter_column('package_kube', 'package_id', existing_type=sa.INTEGER(), nullable=True) op.alter_column('package_kube', 'kube_id', existing_type=sa.INTEGER(), nullable=True) op.alter_column('packages', 'suffix', existing_type=sa.String(length=16), nullable=True) op.alter_column('packages', 'prefix', existing_type=sa.String(length=16), nullable=True) op.alter_column('packages', 'name', existing_type=sa.VARCHAR(length=64), nullable=True) op.create_unique_constraint(u'kubes_is_default_key', 'kubes', ['is_default']) op.drop_index('one_default', table_name='kubes') op.alter_column('kubes', 'name', existing_type=sa.VARCHAR(length=64), nullable=True)
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('pages', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('ts', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('slug', sa.VARCHAR(length=255), autoincrement=False, nullable=False), sa.Column('title', sa.VARCHAR(length=255), autoincrement=False, nullable=False), sa.Column('content', sa.TEXT(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['created_by_id'], [u'users.id'], name=u'pages_created_by_id_fkey'), sa.ForeignKeyConstraint(['modified_by_id'], [u'users.id'], name=u'pages_modified_by_id_fkey'), sa.PrimaryKeyConstraint('id', name=u'pages_pkey') ) op.add_column('menus_items', sa.Column('is_public', sa.BOOLEAN(), autoincrement=False, nullable=True)) op.add_column('menus_items', sa.Column('roles', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.add_column('menus_items', sa.Column('ts', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)) op.add_column('menus_items', sa.Column('page_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('menus_items', sa.Column('is_group_label', sa.BOOLEAN(), autoincrement=False, nullable=True)) op.add_column('menus_items', sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.create_foreign_key(u'menus_items_page_id_fkey', 'menus_items', 'pages', ['page_id'], ['id']) op.create_foreign_key(u'menus_items_created_by_id_fkey', 'menus_items', 'users', ['created_by_id'], ['id']) op.add_column('menus', sa.Column('ts', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)) op.add_column('menus', sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.create_foreign_key(u'menus_created_by_id_fkey', 'menus', 'users', ['created_by_id'], ['id']) op.drop_table('menuitem_roles') ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('conditional', sa.Column('evaluation', sa.INTEGER(), autoincrement=False, nullable=True)) op.drop_constraint(None, 'conditional', type_='foreignkey') op.drop_constraint(None, 'conditional', type_='foreignkey') op.create_foreign_key('conditional_evaluation_fkey', 'conditional', 'spring_evals', ['evaluation'], ['id']) op.drop_column('conditional', 's_evaluation') op.drop_column('conditional', 'i_evaluation') ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('schedule_task', sa.Column('last_run_at', sa.DATETIME(), nullable=True)) op.add_column('schedule_task', sa.Column('total_run_count', sa.INTEGER(), nullable=True)) op.drop_table('schedule_meta') op.drop_table('schedule_info') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('scoreboard', sa.Column('mmr', sa.INTEGER(), autoincrement=False, nullable=False)) op.create_index('ix_scoreboard_mmr', 'scoreboard', ['mmr'], unique=False) op.drop_index(op.f('ix_scoreboard_points'), table_name='scoreboard') op.drop_column('scoreboard', 'points') op.add_column('player_in_match', sa.Column('mmr_before', sa.INTEGER(), autoincrement=False, nullable=False)) op.add_column('player_in_match', sa.Column('mmr_after', sa.INTEGER(), autoincrement=False, nullable=True)) op.drop_column('player_in_match', 'mmr') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('user', sa.Column('vip_mmr', sa.INTEGER(), autoincrement=False, nullable=True)) op.create_index('ix_user_vip_mmr', 'user', ['vip_mmr'], unique=False) # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('law_proposal', sa.Column('law_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('proposal_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['law_id'], [u'law.id'], name=u'law_proposal_law_id_fkey'), sa.ForeignKeyConstraint(['proposal_id'], [u'proposal.id'], name=u'law_proposal_proposal_id_fkey') ) op.drop_table('law_remove') op.drop_table('law_law_group') op.drop_table('law_add') op.drop_table('law_group') # ### end Alembic commands ###
def downgrade(): op.add_column('node', sa.Column('root_disk', sa.VARCHAR(length=80), autoincrement=False, nullable=False)) op.add_column('node', sa.Column('root_partition_size_sectors', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('wipe_root_disk_next_boot', sa.BOOLEAN(), autoincrement=False, nullable=False))
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('cluster', sa.Column('service_account_keypair_id', sa.INTEGER(), autoincrement=False, nullable=False)) op.create_foreign_key('cluster_service_account_keypair_id_fkey', 'cluster', 'credentials_data', ['service_account_keypair_id'], ['id']) op.drop_column('cluster', 'k8s_service_account_public_key') op.drop_column('cluster', 'k8s_service_account_private_key') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('cluster', sa.Column('etcd_version', sa.INTEGER(), autoincrement=False, nullable=False)) # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('category', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=False), sa.PrimaryKeyConstraint('id', name='category_pkey') ) op.drop_table('items_categories') op.drop_table('users') op.drop_index(op.f('ix_items_name'), table_name='items') op.drop_table('items') op.drop_index(op.f('ix_categories_name'), table_name='categories') op.drop_table('categories') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('items_categories', sa.Column('category_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('item_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['category_id'], ['categories.id'], name='items_categories_category_id_fkey'), sa.ForeignKeyConstraint(['item_id'], ['items.id'], name='items_categories_item_id_fkey') ) op.drop_table('categories_items') # ### end Alembic commands ###
def downgrade(): """Downgrade the database to an older revision.""" # commands auto generated by Alembic - please adjust! ### op.add_column('similar_stacks', sa.Column('appstack_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('similar_stacks', sa.Column('dependency_list', postgresql.JSONB(), autoincrement=False, nullable=False)) op.drop_constraint(None, 'similar_stacks', type_='foreignkey') op.drop_constraint(None, 'similar_stacks', type_='foreignkey') op.create_foreign_key('similar_stacks_appstack_id_fkey', 'similar_stacks', 'app_stacks', ['appstack_id'], ['id']) op.drop_constraint('sim_unique', 'similar_stacks', type_='unique') op.drop_column('similar_stacks', 'stack_id') op.drop_column('similar_stacks', 'similarity_value') op.drop_column('similar_stacks', 'similar_stack_id') op.drop_column('similar_stacks', 'analysis') op.create_table('app_stacks', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('stack_json', postgresql.JSONB(), autoincrement=False, nullable=False), sa.PrimaryKeyConstraint('id', name='app_stacks_pkey')) op.create_table('reference_stacks', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False), sa.Column('version', sa.VARCHAR(length=255), autoincrement=False, nullable=False), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=False), sa.Column('dependencies', postgresql.JSONB(), autoincrement=False, nullable=False), sa.PrimaryKeyConstraint('id', name='reference_stacks_pkey'), sa.UniqueConstraint('name', 'version', name='stack_unique')) op.drop_table('stacks') # end Alembic commands ###
def downgrade(): """Downgrade the database to an older revision.""" # commands auto generated by Alembic - please adjust! ### op.create_table('review', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('approved', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('user', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('comment', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('epv', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['user'], ['user.id'], name='review_user_fkey'), sa.PrimaryKeyConstraint('id', name='review_pkey')) # end Alembic commands ###
def downgrade(): """Downgrade the database to an older revision.""" # commands auto generated by Alembic - please adjust! ### op.add_column('analysis_requests', sa.Column('version', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.add_column('analysis_requests', sa.Column('ecosystem', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('analysis_requests', sa.Column('package', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.drop_constraint(None, 'analysis_requests', type_='foreignkey') op.drop_index('epv_index', table_name='analysis_requests') op.create_index('epv_index', 'analysis_requests', ['ecosystem', 'package', 'version'], unique=True) op.drop_column('analysis_requests', 'version_id') op.add_column('analyses', sa.Column('version', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.add_column('analyses', sa.Column('ecosystem', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('analyses', sa.Column('package', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.drop_constraint(None, 'analyses', type_='foreignkey') op.drop_column('analyses', 'version_id') op.drop_table('versions') op.drop_table('packages') op.drop_table('ecosystems') # end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_index('public_tags_value1_idx', 'tags', ['value'], unique=False) op.create_index('public_tags_project_id0_idx', 'tags', ['project_id'], unique=False) op.drop_index(op.f('ix_tags_value'), table_name='tags') op.drop_index(op.f('ix_tags_project_id'), table_name='tags') op.create_table('wikicomment', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('link', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('users_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('datetimeon', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('content', sa.TEXT(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name='wikicomment_pkey') ) ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('node', sa.Column('modules_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('skin_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('type', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('target', sa.VARCHAR(length=80), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('custom', postgresql.BYTEA(), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('folder', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('image', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('folderid', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('parentid', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('node', sa.Column('mods', sa.INTEGER(), autoincrement=False, nullable=True)) op.rename_table('page', 'node') op.execute('ALTER SEQUENCE page_id_seq RENAME TO node_id_seq') op.create_table('modules', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('name', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('title', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('orders', sa.INTEGER(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name='modules_pkey') ) op.create_table('skin', sa.Column('id', sa.INTEGER(), nullable=False), sa.Column('title', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('fname', sa.VARCHAR(length=80), autoincrement=False, nullable=True), sa.Column('orders', sa.INTEGER(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name='skin_pkey') ) # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_column('users', 'password') op.drop_column('users', 'login_count') op.drop_column('users', 'last_login_ip') op.drop_column('users', 'last_login_at') op.drop_column('users', 'current_login_ip') op.drop_column('users', 'current_login_at') op.drop_column('users', 'confirmed_at') op.drop_constraint('tags_project_id_fkey', 'tags', type_='foreignkey') op.alter_column('tags', 'project_id', existing_type=sa.INTEGER(), nullable=True) op.drop_column('tags', 'id') op.drop_constraint('release_project_id_fkey', 'release', type_='foreignkey') op.alter_column('release', 'project_id', existing_type=sa.INTEGER(), nullable=True) op.drop_constraint('projectcomment_users_id_fkey', 'projectcomment', type_='foreignkey') op.drop_constraint('projectcomment_project_id_fkey', 'projectcomment', type_='foreignkey') op.alter_column('projectcomment', 'users_id', existing_type=sa.INTEGER(), nullable=True) op.alter_column('projectcomment', 'project_id', existing_type=sa.INTEGER(), nullable=True) op.drop_constraint('project_user_id_fkey', 'project', type_='foreignkey') op.alter_column('project', 'users_id', existing_type=sa.INTEGER(), nullable=True) op.drop_column('groups', 'description') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_column('artifact', 'type') op.add_column('artifact', sa.Column('type', sa.INTEGER( ), server_default=sa.text('0'), autoincrement=False, nullable=True)) # ### end Alembic commands ###