我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用alembic.op.drop_table()。
def upgrade(): table_prefix = context.config.get_main_option('table_prefix') op.drop_table(table_prefix + 'template') table_name = table_prefix + 'environment_schema_values' with op.batch_alter_table(table_name) as batch: batch.drop_constraint(table_name + '_schema_id_fkey', 'foreignkey') batch.alter_column( 'schema_id', new_column_name='resource_definition_id', existing_type=sa.Integer(), ) op.rename_table(table_name, table_prefix + 'resource_values') op.rename_table(table_prefix + 'schema', table_prefix + 'resource_definition') with op.batch_alter_table(table_prefix + 'resource_definition') as batch: batch.drop_column('namespace_id') op.drop_table(table_prefix + 'namespace') table_name = table_prefix + 'resource_values' with op.batch_alter_table(table_name) as batch: batch.create_foreign_key( table_name + '_resource_definition_id_fkey', table_prefix + 'resource_definition', ['resource_definition_id'], ['id'], )
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('table_columns') op.drop_table('sql_metrics') op.drop_index(op.f('ix_bit_etl_tables_name'), table_name='bit_etl_tables') op.drop_table('bit_etl_tables') op.drop_table('tables') op.drop_table('slice_user') op.drop_table('saved_query') op.drop_index('ti_user_id_changed_on', table_name='query') op.drop_index(op.f('ix_query_results_key'), table_name='query') op.drop_table('query') op.drop_table('dashboard_user') op.drop_table('dashboard_slices') op.drop_table('url') op.drop_table('slices') op.drop_table('logs') op.drop_table('favstar') op.drop_table('dbs') op.drop_table('dashboards') op.drop_table('css_templates') op.drop_table('access_request') op.drop_table('keyvalue') op.drop_table('bit_etl_table_metrics') # ### 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.drop_table('forums') op.drop_table('reports') op.drop_table('topics') op.drop_table('topicsread') op.drop_table('privatemessages') op.drop_table('posts') op.drop_table('moderators') op.drop_table('forumsread') op.drop_table('groups_users') op.drop_table('topictracker') op.drop_table('users') op.drop_table('settings') op.drop_table('settingsgroup') op.drop_table('categories') op.drop_table('groups') ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_likes_timestamp'), table_name='likes') op.drop_table('likes') op.drop_index(op.f('ix_comments_timestamp'), table_name='comments') op.drop_table('comments') op.drop_index(op.f('ix_posts_timestamp'), table_name='posts') op.drop_table('posts') op.drop_table('follows') op.drop_index(op.f('ix_conversations_timestamp'), table_name='conversations') op.drop_table('conversations') op.drop_index(op.f('ix_users_nickname'), table_name='users') op.drop_index(op.f('ix_users_email'), table_name='users') op.drop_table('users') op.drop_index(op.f('ix_roles_default'), table_name='roles') op.drop_table('roles') op.drop_index(op.f('ix_admin_timestamp'), table_name='admin') op.drop_table('admin') # ### 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('menuitem_roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('menuitem_id', sa.Integer(), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['menuitem_id'], ['menus_items.id'], ), sa.ForeignKeyConstraint(['role_id'], ['rbac_role.id'], ), sa.PrimaryKeyConstraint('id') ) op.drop_constraint(u'menus_created_by_id_fkey', 'menus', type_='foreignkey') op.drop_column('menus', 'created_by_id') op.drop_column('menus', 'ts') op.drop_constraint(u'menus_items_created_by_id_fkey', 'menus_items', type_='foreignkey') op.drop_constraint(u'menus_items_page_id_fkey', 'menus_items', type_='foreignkey') op.drop_column('menus_items', 'created_by_id') op.drop_column('menus_items', 'is_group_label') op.drop_column('menus_items', 'page_id') op.drop_column('menus_items', 'roles') op.drop_column('menus_items', 'ts') op.drop_column('menus_items', 'is_public') op.drop_table('pages') ### end Alembic commands ###
def downgrade(): op.drop_table('un_playlistusers') op.drop_table('un_playlisttracks') op.drop_table('un_playlist_images') op.drop_table('un_trackratings') op.drop_index('scrobble_user_index', table_name='un_scrobbles') op.drop_table('un_scrobbles') op.drop_table('un_roles') op.drop_table('un_playqueues') op.drop_table('un_playlists') op.drop_table('un_playcounts') op.drop_table('un_config') op.drop_table('un_artistratings') op.drop_table('un_albumratings') op.drop_table('un_users') op.drop_table('un_dbinfo')
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_table('member_seminar_attendance') op.drop_table('member_hm_attendance') op.drop_table('member_committee_attendance') op.drop_table('freshman_seminar_attendance') op.drop_table('freshman_hm_attendance') op.drop_table('freshman_committee_attendance') op.drop_table('technical_seminars') op.drop_table('spring_evals') op.drop_table('settings') op.drop_table('onfloor_datetime') op.drop_table('major_projects') op.drop_table('housing_evals') op.drop_table('house_meetings') op.drop_table('freshman_eval_data') op.drop_table('freshman_accounts') op.drop_table('current_coops') op.drop_table('conditional') op.drop_table('committee_meetings') ### end Alembic commands ###
def downgrade(): op.drop_table('known_event') op.drop_table('chart') op.drop_table('variable') op.drop_table('user') op.drop_index('ti_state_lkp', table_name='task_instance') op.drop_index('ti_pool', table_name='task_instance') op.drop_index('ti_dag_state', table_name='task_instance') op.drop_table('task_instance') op.drop_table('slot_pool') op.drop_table('sla_miss') op.drop_table('log') op.drop_table('known_event_type') op.drop_index('job_type_heart', table_name='job') op.drop_table('job') op.drop_table('import_error') op.drop_table('dag_pickle') op.drop_table('dag') op.drop_table('connection') op.drop_table('xcom')
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_user_mix_details_refresh_date'), table_name='user_mix_details') op.drop_table('user_mix_details') op.drop_index(op.f('ix_queued_player_added'), table_name='queued_player') op.drop_table('queued_player') op.drop_table('profile_scan_info') op.drop_table('player_in_match') op.drop_table('permissions') op.drop_index(op.f('ix_user_nickname'), table_name='user') op.drop_table('user') op.drop_table('user_permission') op.drop_index(op.f('ix_match_status'), table_name='match') op.drop_index(op.f('ix_match_created'), table_name='match') op.drop_table('match') ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_table('potocas') op.drop_index('ix_comments_timestamp', 'comments') op.drop_table('comments') op.drop_table('usertocas') op.drop_index('ix_questions_timestamp', 'questions') op.drop_table('questions') op.drop_table('follows') op.drop_index('ix_users_username', 'users') op.drop_index('ix_users_email', 'users') op.drop_table('users') op.drop_table('categories') op.drop_index('ix_roles_default', 'roles') op.drop_table('roles') ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.alter_column(u'users', 'user_id', existing_type=sa.VARCHAR(length=100), nullable=True) op.alter_column(u'users', 'updated_at', existing_type=postgresql.TIMESTAMP(), nullable=True) op.alter_column(u'users', 'name', existing_type=sa.VARCHAR(length=100), nullable=True) op.alter_column(u'users', 'last_name', existing_type=sa.VARCHAR(length=200), nullable=True) op.alter_column(u'users', 'email', existing_type=sa.VARCHAR(length=150), nullable=True) op.alter_column(u'users', 'created_at', existing_type=postgresql.TIMESTAMP(), nullable=True) op.drop_table('request_referral') ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_table('distributed_query_result') op.drop_table('status_log') op.drop_table('result_log') op.drop_table('query_tags') op.drop_table('query_packs') op.drop_table('pack_tags') op.drop_table('node_tags') op.drop_table('file_path_tags') op.drop_table('distributed_query') op.drop_table('tag') op.drop_table('query') op.drop_table('pack') op.drop_table('node') op.drop_table('file_path') ### end Alembic commands ###
def downgrade(): table_prefix = context.config.get_main_option('table_prefix') op.drop_table(table_prefix + 'repos')
def downgrade(): table_prefix = context.config.get_main_option('table_prefix') op.drop_table(table_prefix + 'changes_whitelist')
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('answers') op.drop_table('questions') op.drop_table('users') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('user_subscription') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('likes') op.drop_table('user_tag') op.drop_table('free_tag') op.drop_table('file_tag') op.drop_table('custom_tag') op.drop_table('comment') op.drop_table('thread') op.drop_table('named_tag') op.drop_table('branch') op.drop_table('project') op.drop_table('user') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('user_read_thread') # ### end Alembic commands ###
def downgrade(): op.drop_table('network_interfaces') op.drop_index(op.f('ix_devices_labels'), table_name='labels') op.drop_table('labels') op.drop_table('network_devices') op.drop_table('hosts') op.drop_index(op.f('ix_networks_region_id'), table_name='networks') op.drop_index(op.f('ix_networks_cloud_id'), table_name='networks') op.drop_index(op.f('ix_networks_project_id'), table_name='networks') op.drop_index(op.f('ix_networks_cell_id'), table_name='networks') op.drop_table('networks') op.drop_index(op.f('ix_devices_region_id'), table_name='devices') op.drop_index(op.f('ix_devices_cloud_id'), table_name='devices') op.drop_index(op.f('ix_devices_project_id'), table_name='devices') op.drop_index(op.f('ix_devices_cell_id'), table_name='devices') op.drop_table('devices') op.drop_index(op.f('ix_cells_region_id'), table_name='cells') op.drop_index(op.f('ix_cells_cloud_id'), table_name='cells') op.drop_index(op.f('ix_cells_project_id'), table_name='cells') op.drop_table('cells') op.drop_index(op.f('ix_users_project_id'), table_name='users') op.drop_index(op.f('ix_regions_project_id'), table_name='regions') op.drop_index(op.f('ix_regions_cloud_id'), table_name='regions') op.drop_table('regions') op.drop_index(op.f('ix_clouds_project_id'), table_name='clouds') op.drop_table('clouds') op.drop_table('users') op.drop_table('projects') op.drop_index(op.f('ix_variable_keys'), table_name='variables') op.drop_table('variables') op.drop_table('variable_association')
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_table('inpatientlocation') op.drop_table('subscription') op.drop_table('result') op.drop_table('patientidentifier') op.drop_table('patient') op.drop_table('merge') op.drop_table('inpatientepisode') op.drop_table('allergy') op.drop_table('glossolaliareference') op.drop_table('error') ### end Alembic commands ###
def upgrade(): op.drop_table('inpatientlocation') op.drop_table('inpatientepisode') op.create_table('inpatientadmission', sa.Column('id', sa.Integer(), nullable=False), sa.Column('updated', sa.DateTime(), nullable=True), sa.Column('created', sa.DateTime(), nullable=True), sa.Column('datetime_of_admission', sa.DateTime(), nullable=False), sa.Column('datetime_of_discharge', sa.DateTime(), nullable=True), sa.Column('visit_number', sa.String(length=250), nullable=False), sa.Column('admission_diagnosis', sa.String(length=250), nullable=True), sa.Column('gloss_reference_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['gloss_reference_id'], ['glossolaliareference.id'], ), sa.PrimaryKeyConstraint('id') ) 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_admission_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_admission_id'], ['inpatientadmission.id'], ), sa.PrimaryKeyConstraint('id') ) ### 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(): op.drop_table('counter')
def downgrade(): op.drop_table('project_stats')
def downgrade(): op.drop_table('announcement')
def upgrade(): # First, create column and fill all records with default value. # To avoid integrity error, the constraint non-nullable will be set after that op.add_column('app', sa.Column('featured', sa.Boolean, default=False)) query = 'UPDATE "app" SET featured=false;' op.execute(query) op.alter_column('app', 'featured', nullable=False) query = 'UPDATE "app" SET featured=true WHERE app.id IN (SELECT app_id FROM FEATURED);' op.execute(query) op.drop_table('featured')
def downgrade(): op.drop_table('featured')
def downgrade(): op.drop_table('result')
def downgrade(): op.drop_table('category')
def downgrade(): op.drop_table('blogpost')
def downgrade(): op.drop_table('auditlog')
def downgrade(): op.drop_table('helpingmaterial')
def downgrade(): table_prefix = context.config.get_main_option('table_prefix') op.drop_table(table_prefix + 'environment_schema_values') op.drop_table(table_prefix + 'environment_hierarchy_level_value') op.drop_table(table_prefix + 'template') op.drop_table(table_prefix + 'schema') op.drop_table(table_prefix + 'environment_hierarchy_level') op.drop_table(table_prefix + 'environment_components') op.drop_table(table_prefix + 'namespace') op.drop_table(table_prefix + 'environment') op.drop_table(table_prefix + 'component')
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_table('identity') ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_table('session') op.drop_table('user') ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('bit_facebook_daily_ad_insights') # ### end Alembic commands ###
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('bit_appsflyer_connector', sa.Column('connector_id', sa.Integer(), nullable=False), sa.Column('app_id', sa.String(length=255), nullable=True), sa.Column('api_token', sa.String(length=255), nullable=True), sa.Column('url_pat', sa.String(length=255), nullable=True), sa.ForeignKeyConstraint(['connector_id'], ['bit_connectors.id'], ), sa.PrimaryKeyConstraint('connector_id') ) op.drop_table('bit_connectors_appsflyer') # ### 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.drop_index(op.f('ix_bit_performance_report_year'), table_name='bit_performance_report') op.drop_index(op.f('ix_bit_performance_report_name'), table_name='bit_performance_report') op.drop_index(op.f('ix_bit_performance_report_month'), table_name='bit_performance_report') op.drop_index(op.f('ix_bit_performance_report_day'), table_name='bit_performance_report') op.drop_index(op.f('ix_bit_performance_report_date'), table_name='bit_performance_report') op.drop_index(op.f('ix_bit_performance_report_campaign_source'), table_name='bit_performance_report') op.drop_index(op.f('ix_bit_performance_report_campaign_name'), table_name='bit_performance_report') op.drop_index(op.f('ix_bit_performance_report_campaign_id'), table_name='bit_performance_report') op.drop_index(op.f('ix_bit_performance_report_breakdowns'), table_name='bit_performance_report') op.drop_table('bit_performance_report') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('bit_analytics_identify') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_bit_facebook_ad_campaigns_status'), table_name='bit_facebook_ad_campaigns') op.drop_index(op.f('ix_bit_facebook_ad_campaigns_native_id'), table_name='bit_facebook_ad_campaigns') op.drop_table('bit_facebook_ad_campaigns') op.drop_index(op.f('ix_bit_facebook_ad_account_native_id'), table_name='bit_facebook_ad_account') op.drop_index(op.f('ix_bit_facebook_ad_account_account_id'), table_name='bit_facebook_ad_account') op.drop_table('bit_facebook_ad_account') op.drop_table('bit_facebook_connector') op.drop_index(op.f('ix_bit_facebook_ad_sets_status'), table_name='bit_facebook_ad_sets') op.drop_index(op.f('ix_bit_facebook_ad_sets_native_id'), table_name='bit_facebook_ad_sets') op.drop_table('bit_facebook_ad_sets') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('bit_adwords_google_drive_storage') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_bit_adwords_campaign_performance_report_impression_device'), table_name='bit_adwords_campaign_performance_report') op.drop_table('bit_adwords_campaign_performance_report') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('bit_chiter_connector') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_bit_data_source_info_sync_time'), table_name='bit_data_source_info') op.drop_index(op.f('ix_bit_data_source_info_source'), table_name='bit_data_source_info') op.drop_index(op.f('ix_bit_data_source_info_name'), table_name='bit_data_source_info') op.drop_index(op.f('ix_bit_data_source_info_last_id'), table_name='bit_data_source_info') op.drop_table('bit_data_source_info') # ### end Alembic commands ###