From 64c5f94db63f4309e6357d8d403413b437f4ffee Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Fri, 22 Nov 2024 13:03:00 -0800 Subject: [PATCH] feat(migrations): Prevent new migrations from using `RunSQL` (#81003) This adds in `allow_run_sql` to our `CheckedMigration` baseclass. We want to prevent the use of `RunSQL` in most cases going forward, since our migration safety framework doesn't know how to parse sql to ensure safety. Our main uses for this in the past were: - Adding new columns with a default. We now can do this within the framework by using `db_default` instead of `default`. - Deleting columns/tables. Since we have to remove from state, deploy, then delete we have to use raw sql to remove them from Postgres. I'll follow this up with a pr to provide ways to handle these deletions within our framework. --- .../bad_flow_run_sql_disabled_app/__init__.py | 0 .../migrations/0001_initial.py | 16 ++++++++++++++ .../migrations/__init__.py | 0 .../bad_flow_run_sql_disabled_app/models.py | 5 +++++ .../migrations/0002_delete_model_state.py | 13 +++-------- .../migrations/0003_delete_table.py | 9 ++++---- .../good_flow_run_sql_enabled_app/__init__.py | 0 .../migrations/0001_initial.py | 16 ++++++++++++++ .../migrations/__init__.py | 0 .../good_flow_run_sql_enabled_app/models.py | 5 +++++ .../0003_add_scopes_to_api_key_replica.py | 2 ++ ..._squashed_0484_break_org_member_user_fk.py | 2 ++ .../migrations/0490_add_is_test_to_org.py | 2 ++ ...491_remove_orgmemmap_unique_constraints.py | 2 ++ .../0505_debugfile_date_accessed.py | 2 ++ .../migrations/0526_pr_comment_type_column.py | 2 ++ .../0535_add_created_date_to_outbox_model.py | 2 ++ .../0544_remove_groupsubscription_columns.py | 2 ++ ...45_add_last_verified_auth_ident_replica.py | 2 ++ .../0548_add_is_unclaimed_boolean_to_user.py | 2 ++ .../0549_re_add_groupsubscription_columns.py | 2 ++ ...ganizationmapping_replicate_require_2fa.py | 2 ++ ...commitfilechange_delete_language_column.py | 2 ++ .../0570_repository_add_languages_column.py | 2 ++ ...d_early_adopter_to_organization_mapping.py | 2 ++ .../0590_add_metadata_to_sentry_app.py | 2 ++ ...ve_relocation_hybrid_cloud_foreign_keys.py | 2 ++ ...te_relocation_hybrid_cloud_foreign_keys.py | 2 ++ .../0607_drop_externalactor_actorid.py | 2 ++ .../0610_remove_notification_setting_table.py | 2 ++ ...7_monitor_boolean_fields_muted_disabled.py | 2 ++ ...nt_user_id_from_userreport_table_step_2.py | 2 ++ .../0624_add_is_muted_monitorenvironment.py | 2 ++ ..._add_priority_columns_to_groupedmessage.py | 2 ++ ...dd_priority_locked_at_to_groupedmessage.py | 2 ++ ...0637_remove_pr_comment_pr_id_constraint.py | 2 ++ ...ate_added_to_dashboard_widget_on_demand.py | 2 ++ ...ate_modified_col_dashboard_widget_query.py | 2 ++ .../0651_enable_activated_alert_rules.py | 2 ++ ...us_column_for_alert_rule_trigger_action.py | 2 ++ .../migrations/0658_projectkey_usecase.py | 2 ++ .../0663_artifactbundleindex_cleanup_step3.py | 2 ++ .../0665_monitor_drop_last_state_change_db.py | 2 ++ ...78_add_is_hidden_dashboard_widget_query.py | 2 ++ ...2_monitors_constrain_to_project_id_slug.py | 2 ++ .../0689_drop_config_from_cron_checkin.py | 2 ++ .../0697_remove_monitor_owner_actor_id_db.py | 2 ++ .../0700_drop_fileid_controlavatar.py | 2 ++ ...707_alert_rule_activations_incidents_fk.py | 2 ++ .../0709_alertrule_remove_owner_state.py | 2 ++ .../0710_grouphistory_remove_actor_state.py | 2 ++ .../0713_team_remove_actor_state.py | 2 ++ .../0714_drop_project_team_avatar.py | 2 ++ .../0715_remove_actormodel_constraints.py | 2 ++ ...subscription_timebox_column_deletion_db.py | 2 ++ .../migrations/0720_remove_actor_columns.py | 2 ++ .../migrations/0722_drop_sentryfunctions.py | 2 ++ .../0724_discover_saved_query_dataset.py | 2 ++ ...725_create_sentry_groupsearchview_table.py | 2 ++ .../migrations/0733_relocation_provenance.py | 2 ++ ...add_discover_saved_query_dataset_source.py | 2 ++ .../migrations/0738_rm_reprocessing_step3.py | 2 ++ .../0741_metric_alert_anomaly_detection.py | 2 ++ ..._add_dataset_source_field_to_dashboards.py | 2 ++ .../0746_add_bitflags_to_hybrid_cloud.py | 2 ++ ...0_disable_member_invite_in_hybrid_cloud.py | 2 ++ .../0757_add_scopes_to_apiapplication.py | 2 ++ ...9_remove_spanattributeextraction_tables.py | 2 ++ ...ove_appstore_connect_integration_tables.py | 2 ++ .../0776_drop_group_score_in_database.py | 2 ++ ..._add_new_field_to_dashboard_permissions.py | 2 ++ .../0786_drop_broadcasts_cta_column.py | 2 ++ .../0790_delete_dashboard_perms_col.py | 2 ++ src/sentry/new_migrations/migrations.py | 16 +++++++++++++- .../0003_drop_remote_subscription.py | 2 ++ ...002_remove_separate_remote_subscription.py | 2 ++ .../0003_drop_remote_subscription.py | 2 ++ .../0004_projectuptimesubscription_mode.py | 2 ++ .../uptime/migrations/0005_uptime_status.py | 2 ++ ...06_projectuptimesubscription_name_owner.py | 2 ++ .../migrations/0008_uptime_url_suffix.py | 2 ++ .../0011_remove_uptime_whois_columns_db.py | 2 ++ ...0012_uptime_subscription_request_fields.py | 2 ++ ...0018_add_trace_sampling_field_to_uptime.py | 2 ++ .../0010_detector_state_unique_group.py | 2 ++ .../integration/test_migrations.py | 22 +++++++++++++++++++ 86 files changed, 234 insertions(+), 16 deletions(-) create mode 100644 fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/__init__.py create mode 100644 fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/migrations/0001_initial.py create mode 100644 fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/migrations/__init__.py create mode 100644 fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/models.py create mode 100644 fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/__init__.py create mode 100644 fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/migrations/0001_initial.py create mode 100644 fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/migrations/__init__.py create mode 100644 fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/models.py diff --git a/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/__init__.py b/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/migrations/0001_initial.py b/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/migrations/0001_initial.py new file mode 100644 index 0000000000000..8d119afd02862 --- /dev/null +++ b/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/migrations/0001_initial.py @@ -0,0 +1,16 @@ +# Generated by Django 3.1 on 2019-09-22 21:47 + +from django.db import migrations + +from sentry.new_migrations.migrations import CheckedMigration + + +class Migration(CheckedMigration): + + initial = True + + dependencies = [] + + allow_run_sql = False + + operations = [migrations.RunSQL("select 1;")] diff --git a/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/migrations/__init__.py b/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/migrations/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/models.py b/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/models.py new file mode 100644 index 0000000000000..770fa149c355c --- /dev/null +++ b/fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/models.py @@ -0,0 +1,5 @@ +from django.db import models + + +class TestTable(models.Model): + field = models.IntegerField(default=0, null=False) diff --git a/fixtures/safe_migrations_apps/good_flow_delete_model_state_app/migrations/0002_delete_model_state.py b/fixtures/safe_migrations_apps/good_flow_delete_model_state_app/migrations/0002_delete_model_state.py index aa7a0b3105125..4d9779f1c977f 100644 --- a/fixtures/safe_migrations_apps/good_flow_delete_model_state_app/migrations/0002_delete_model_state.py +++ b/fixtures/safe_migrations_apps/good_flow_delete_model_state_app/migrations/0002_delete_model_state.py @@ -1,8 +1,7 @@ # Generated by Django 3.1 on 2019-09-22 21:47 - -from django.db import migrations - from sentry.new_migrations.migrations import CheckedMigration +from sentry.new_migrations.monkey.models import SafeDeleteModel +from sentry.new_migrations.monkey.state import DeletionAction class Migration(CheckedMigration): @@ -12,11 +11,5 @@ class Migration(CheckedMigration): ] operations = [ - migrations.SeparateDatabaseAndState( - state_operations=[ - migrations.DeleteModel( - name="TestTable", - ), - ] - ) + SafeDeleteModel(name="TestTable", deletion_action=DeletionAction.MOVE_TO_PENDING), ] diff --git a/fixtures/safe_migrations_apps/good_flow_delete_model_state_app/migrations/0003_delete_table.py b/fixtures/safe_migrations_apps/good_flow_delete_model_state_app/migrations/0003_delete_table.py index f0a85b49040a3..8a6e05080a31b 100644 --- a/fixtures/safe_migrations_apps/good_flow_delete_model_state_app/migrations/0003_delete_table.py +++ b/fixtures/safe_migrations_apps/good_flow_delete_model_state_app/migrations/0003_delete_table.py @@ -1,16 +1,15 @@ # Generated by Django 3.1 on 2019-09-22 21:47 - -from django.db import migrations - from sentry.new_migrations.migrations import CheckedMigration +from sentry.new_migrations.monkey.models import SafeDeleteModel +from sentry.new_migrations.monkey.state import DeletionAction class Migration(CheckedMigration): dependencies = [ - ("good_flow_delete_model_state_app", "0001_initial"), + ("good_flow_delete_model_state_app", "0002_delete_model_state"), ] operations = [ - migrations.RunSQL('DROP TABLE "good_flow_delete_model_state_app_testtable";'), + SafeDeleteModel(name="TestTable", deletion_action=DeletionAction.DELETE), ] diff --git a/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/__init__.py b/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/migrations/0001_initial.py b/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/migrations/0001_initial.py new file mode 100644 index 0000000000000..8939a5ba3393b --- /dev/null +++ b/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/migrations/0001_initial.py @@ -0,0 +1,16 @@ +# Generated by Django 3.1 on 2019-09-22 21:47 + +from django.db import migrations + +from sentry.new_migrations.migrations import CheckedMigration + + +class Migration(CheckedMigration): + + initial = True + + dependencies = [] + + allow_run_sql = True + + operations = [migrations.RunSQL("select 1;")] diff --git a/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/migrations/__init__.py b/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/migrations/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/models.py b/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/models.py new file mode 100644 index 0000000000000..770fa149c355c --- /dev/null +++ b/fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/models.py @@ -0,0 +1,5 @@ +from django.db import models + + +class TestTable(models.Model): + field = models.IntegerField(default=0, null=False) diff --git a/src/sentry/hybridcloud/migrations/0003_add_scopes_to_api_key_replica.py b/src/sentry/hybridcloud/migrations/0003_add_scopes_to_api_key_replica.py index 320d680a87853..092ed71bbc5cc 100644 --- a/src/sentry/hybridcloud/migrations/0003_add_scopes_to_api_key_replica.py +++ b/src/sentry/hybridcloud/migrations/0003_add_scopes_to_api_key_replica.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("hybridcloud", "0002_add_slug_reservation_replica_model"), ] diff --git a/src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py b/src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py index 5592f4a25a27a..16ef15658ea34 100644 --- a/src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py +++ b/src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py @@ -54,6 +54,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + replaces = [ ("sentry", "0001_squashed_0200_release_indices"), ("sentry", "0201_semver_package"), diff --git a/src/sentry/migrations/0490_add_is_test_to_org.py b/src/sentry/migrations/0490_add_is_test_to_org.py index 5ea600ad4cf02..398394ba1409c 100644 --- a/src/sentry/migrations/0490_add_is_test_to_org.py +++ b/src/sentry/migrations/0490_add_is_test_to_org.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0489_index_checkin_timeout"), ] diff --git a/src/sentry/migrations/0491_remove_orgmemmap_unique_constraints.py b/src/sentry/migrations/0491_remove_orgmemmap_unique_constraints.py index a239fb9823780..4e30ad2812ad4 100644 --- a/src/sentry/migrations/0491_remove_orgmemmap_unique_constraints.py +++ b/src/sentry/migrations/0491_remove_orgmemmap_unique_constraints.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0490_add_is_test_to_org"), ] diff --git a/src/sentry/migrations/0505_debugfile_date_accessed.py b/src/sentry/migrations/0505_debugfile_date_accessed.py index c39b0755a95d9..ff60d15fe6bba 100644 --- a/src/sentry/migrations/0505_debugfile_date_accessed.py +++ b/src/sentry/migrations/0505_debugfile_date_accessed.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0504_add_artifact_bundle_index"), ] diff --git a/src/sentry/migrations/0526_pr_comment_type_column.py b/src/sentry/migrations/0526_pr_comment_type_column.py index 3bfa0f8575e77..1791094fdecd7 100644 --- a/src/sentry/migrations/0526_pr_comment_type_column.py +++ b/src/sentry/migrations/0526_pr_comment_type_column.py @@ -21,6 +21,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0525_add_next_checkin_latest"), ] diff --git a/src/sentry/migrations/0535_add_created_date_to_outbox_model.py b/src/sentry/migrations/0535_add_created_date_to_outbox_model.py index 179daa393d181..abff576652816 100644 --- a/src/sentry/migrations/0535_add_created_date_to_outbox_model.py +++ b/src/sentry/migrations/0535_add_created_date_to_outbox_model.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0534_add_notification_uuid_to_rule_fire_history"), ] diff --git a/src/sentry/migrations/0544_remove_groupsubscription_columns.py b/src/sentry/migrations/0544_remove_groupsubscription_columns.py index 10f9262420987..bc6ad90444e2d 100644 --- a/src/sentry/migrations/0544_remove_groupsubscription_columns.py +++ b/src/sentry/migrations/0544_remove_groupsubscription_columns.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0543_add_team_id_to_groupsubscription"), ] diff --git a/src/sentry/migrations/0545_add_last_verified_auth_ident_replica.py b/src/sentry/migrations/0545_add_last_verified_auth_ident_replica.py index b24ed73981810..71a4ebafc2093 100644 --- a/src/sentry/migrations/0545_add_last_verified_auth_ident_replica.py +++ b/src/sentry/migrations/0545_add_last_verified_auth_ident_replica.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0544_remove_groupsubscription_columns"), ] diff --git a/src/sentry/migrations/0548_add_is_unclaimed_boolean_to_user.py b/src/sentry/migrations/0548_add_is_unclaimed_boolean_to_user.py index 324603794f785..6e2ae09594062 100644 --- a/src/sentry/migrations/0548_add_is_unclaimed_boolean_to_user.py +++ b/src/sentry/migrations/0548_add_is_unclaimed_boolean_to_user.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0547_add_commitfilechange_language_column"), ] diff --git a/src/sentry/migrations/0549_re_add_groupsubscription_columns.py b/src/sentry/migrations/0549_re_add_groupsubscription_columns.py index f124f9337c4f8..4468a981c603b 100644 --- a/src/sentry/migrations/0549_re_add_groupsubscription_columns.py +++ b/src/sentry/migrations/0549_re_add_groupsubscription_columns.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = True + allow_run_sql = True + dependencies = [ ("sentry", "0548_add_is_unclaimed_boolean_to_user"), ] diff --git a/src/sentry/migrations/0556_organizationmapping_replicate_require_2fa.py b/src/sentry/migrations/0556_organizationmapping_replicate_require_2fa.py index e249bd0d688fd..3185e6373b831 100644 --- a/src/sentry/migrations/0556_organizationmapping_replicate_require_2fa.py +++ b/src/sentry/migrations/0556_organizationmapping_replicate_require_2fa.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0555_set_neglectedrule_email_date_columns_nullable"), ] diff --git a/src/sentry/migrations/0564_commitfilechange_delete_language_column.py b/src/sentry/migrations/0564_commitfilechange_delete_language_column.py index c29268441b68d..9a5cc11a0d9ee 100644 --- a/src/sentry/migrations/0564_commitfilechange_delete_language_column.py +++ b/src/sentry/migrations/0564_commitfilechange_delete_language_column.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0563_commitfilechange_drop_language_column"), ] diff --git a/src/sentry/migrations/0570_repository_add_languages_column.py b/src/sentry/migrations/0570_repository_add_languages_column.py index 8d61069af4bbd..9b7cd95383156 100644 --- a/src/sentry/migrations/0570_repository_add_languages_column.py +++ b/src/sentry/migrations/0570_repository_add_languages_column.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0569_dashboard_widgets_indicator"), ] diff --git a/src/sentry/migrations/0583_add_early_adopter_to_organization_mapping.py b/src/sentry/migrations/0583_add_early_adopter_to_organization_mapping.py index 8d87de590a53d..5641c4e1d47a1 100644 --- a/src/sentry/migrations/0583_add_early_adopter_to_organization_mapping.py +++ b/src/sentry/migrations/0583_add_early_adopter_to_organization_mapping.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0582_add_status_indexes_checkins"), ] diff --git a/src/sentry/migrations/0590_add_metadata_to_sentry_app.py b/src/sentry/migrations/0590_add_metadata_to_sentry_app.py index 70467066f7a0b..17c605b63b648 100644 --- a/src/sentry/migrations/0590_add_metadata_to_sentry_app.py +++ b/src/sentry/migrations/0590_add_metadata_to_sentry_app.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0589_add_commit_date_added_indices"), ] diff --git a/src/sentry/migrations/0591_remove_relocation_hybrid_cloud_foreign_keys.py b/src/sentry/migrations/0591_remove_relocation_hybrid_cloud_foreign_keys.py index 9504b752d61be..d4702555a7298 100644 --- a/src/sentry/migrations/0591_remove_relocation_hybrid_cloud_foreign_keys.py +++ b/src/sentry/migrations/0591_remove_relocation_hybrid_cloud_foreign_keys.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0590_add_metadata_to_sentry_app"), ] diff --git a/src/sentry/migrations/0592_delete_relocation_hybrid_cloud_foreign_keys.py b/src/sentry/migrations/0592_delete_relocation_hybrid_cloud_foreign_keys.py index f184baa6f8390..6ce84ad9f211e 100644 --- a/src/sentry/migrations/0592_delete_relocation_hybrid_cloud_foreign_keys.py +++ b/src/sentry/migrations/0592_delete_relocation_hybrid_cloud_foreign_keys.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0591_remove_relocation_hybrid_cloud_foreign_keys"), ] diff --git a/src/sentry/migrations/0607_drop_externalactor_actorid.py b/src/sentry/migrations/0607_drop_externalactor_actorid.py index 6f7bf3fd11868..6052d52bb1aa2 100644 --- a/src/sentry/migrations/0607_drop_externalactor_actorid.py +++ b/src/sentry/migrations/0607_drop_externalactor_actorid.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0606_update_user_to_optional_organization_slug_reservation"), ] diff --git a/src/sentry/migrations/0610_remove_notification_setting_table.py b/src/sentry/migrations/0610_remove_notification_setting_table.py index 47dfb155e353a..e88cf1a990ec6 100644 --- a/src/sentry/migrations/0610_remove_notification_setting_table.py +++ b/src/sentry/migrations/0610_remove_notification_setting_table.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0609_remove_notification_setting_model"), ] diff --git a/src/sentry/migrations/0617_monitor_boolean_fields_muted_disabled.py b/src/sentry/migrations/0617_monitor_boolean_fields_muted_disabled.py index fe25887609f43..040d95c6bfcce 100644 --- a/src/sentry/migrations/0617_monitor_boolean_fields_muted_disabled.py +++ b/src/sentry/migrations/0617_monitor_boolean_fields_muted_disabled.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0616_drop_event_user_id_from_userreport_table_step_1"), ] diff --git a/src/sentry/migrations/0618_drop_event_user_id_from_userreport_table_step_2.py b/src/sentry/migrations/0618_drop_event_user_id_from_userreport_table_step_2.py index 0a2d77ed6ca01..60c5c7d3c100c 100644 --- a/src/sentry/migrations/0618_drop_event_user_id_from_userreport_table_step_2.py +++ b/src/sentry/migrations/0618_drop_event_user_id_from_userreport_table_step_2.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0617_monitor_boolean_fields_muted_disabled"), ] diff --git a/src/sentry/migrations/0624_add_is_muted_monitorenvironment.py b/src/sentry/migrations/0624_add_is_muted_monitorenvironment.py index 9d36e7039b153..28437b53203c1 100644 --- a/src/sentry/migrations/0624_add_is_muted_monitorenvironment.py +++ b/src/sentry/migrations/0624_add_is_muted_monitorenvironment.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0623_increase_regression_fingerprint_length"), ] diff --git a/src/sentry/migrations/0631_add_priority_columns_to_groupedmessage.py b/src/sentry/migrations/0631_add_priority_columns_to_groupedmessage.py index fdad116dc7ee4..6dffdce9d51f1 100644 --- a/src/sentry/migrations/0631_add_priority_columns_to_groupedmessage.py +++ b/src/sentry/migrations/0631_add_priority_columns_to_groupedmessage.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0630_better_monitor_latest_index"), ] diff --git a/src/sentry/migrations/0633_add_priority_locked_at_to_groupedmessage.py b/src/sentry/migrations/0633_add_priority_locked_at_to_groupedmessage.py index f0639df01f5e0..25c185d415142 100644 --- a/src/sentry/migrations/0633_add_priority_locked_at_to_groupedmessage.py +++ b/src/sentry/migrations/0633_add_priority_locked_at_to_groupedmessage.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0632_apitoken_backfill_last_chars"), ] diff --git a/src/sentry/migrations/0637_remove_pr_comment_pr_id_constraint.py b/src/sentry/migrations/0637_remove_pr_comment_pr_id_constraint.py index 2c7a45b552bbf..c06a425026ca2 100644 --- a/src/sentry/migrations/0637_remove_pr_comment_pr_id_constraint.py +++ b/src/sentry/migrations/0637_remove_pr_comment_pr_id_constraint.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0636_monitor_incident_env_resolving_index"), ] diff --git a/src/sentry/migrations/0638_add_date_added_to_dashboard_widget_on_demand.py b/src/sentry/migrations/0638_add_date_added_to_dashboard_widget_on_demand.py index dc5e9246bdb97..b759ff0f296f5 100644 --- a/src/sentry/migrations/0638_add_date_added_to_dashboard_widget_on_demand.py +++ b/src/sentry/migrations/0638_add_date_added_to_dashboard_widget_on_demand.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0637_remove_pr_comment_pr_id_constraint"), ] diff --git a/src/sentry/migrations/0643_add_date_modified_col_dashboard_widget_query.py b/src/sentry/migrations/0643_add_date_modified_col_dashboard_widget_query.py index 1c6498a4817af..09068d3885070 100644 --- a/src/sentry/migrations/0643_add_date_modified_col_dashboard_widget_query.py +++ b/src/sentry/migrations/0643_add_date_modified_col_dashboard_widget_query.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0642_index_together_release"), ] diff --git a/src/sentry/migrations/0651_enable_activated_alert_rules.py b/src/sentry/migrations/0651_enable_activated_alert_rules.py index 60408e2a6f477..4e1d2640b9edc 100644 --- a/src/sentry/migrations/0651_enable_activated_alert_rules.py +++ b/src/sentry/migrations/0651_enable_activated_alert_rules.py @@ -23,6 +23,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0650_create_sentryshot"), ] diff --git a/src/sentry/migrations/0657_add_status_column_for_alert_rule_trigger_action.py b/src/sentry/migrations/0657_add_status_column_for_alert_rule_trigger_action.py index d1d5dc69bbc3d..31fbdf83276a7 100644 --- a/src/sentry/migrations/0657_add_status_column_for_alert_rule_trigger_action.py +++ b/src/sentry/migrations/0657_add_status_column_for_alert_rule_trigger_action.py @@ -19,6 +19,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0656_add_discover_dataset_split_dashboard"), ] diff --git a/src/sentry/migrations/0658_projectkey_usecase.py b/src/sentry/migrations/0658_projectkey_usecase.py index 721f564704bce..84964091d4aa0 100644 --- a/src/sentry/migrations/0658_projectkey_usecase.py +++ b/src/sentry/migrations/0658_projectkey_usecase.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0657_add_status_column_for_alert_rule_trigger_action"), ] diff --git a/src/sentry/migrations/0663_artifactbundleindex_cleanup_step3.py b/src/sentry/migrations/0663_artifactbundleindex_cleanup_step3.py index 70ec590c959b6..670b5d9aa5bb6 100644 --- a/src/sentry/migrations/0663_artifactbundleindex_cleanup_step3.py +++ b/src/sentry/migrations/0663_artifactbundleindex_cleanup_step3.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0662_monitor_drop_last_state_change"), ] diff --git a/src/sentry/migrations/0665_monitor_drop_last_state_change_db.py b/src/sentry/migrations/0665_monitor_drop_last_state_change_db.py index dbef628771474..56e9a741d8020 100644 --- a/src/sentry/migrations/0665_monitor_drop_last_state_change_db.py +++ b/src/sentry/migrations/0665_monitor_drop_last_state_change_db.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0664_create_new_broken_monitor_detection_table"), ] diff --git a/src/sentry/migrations/0678_add_is_hidden_dashboard_widget_query.py b/src/sentry/migrations/0678_add_is_hidden_dashboard_widget_query.py index d45b47230af02..6f6fb4a07250d 100644 --- a/src/sentry/migrations/0678_add_is_hidden_dashboard_widget_query.py +++ b/src/sentry/migrations/0678_add_is_hidden_dashboard_widget_query.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0677_unpickle_project_options_again"), ] diff --git a/src/sentry/migrations/0682_monitors_constrain_to_project_id_slug.py b/src/sentry/migrations/0682_monitors_constrain_to_project_id_slug.py index c6a78343712ec..1bf094a158209 100644 --- a/src/sentry/migrations/0682_monitors_constrain_to_project_id_slug.py +++ b/src/sentry/migrations/0682_monitors_constrain_to_project_id_slug.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = True + allow_run_sql = True + dependencies = [ ("sentry", "0681_unpickle_authenticator_again"), ] diff --git a/src/sentry/migrations/0689_drop_config_from_cron_checkin.py b/src/sentry/migrations/0689_drop_config_from_cron_checkin.py index 724035f46302c..e2165fe3b044b 100644 --- a/src/sentry/migrations/0689_drop_config_from_cron_checkin.py +++ b/src/sentry/migrations/0689_drop_config_from_cron_checkin.py @@ -18,6 +18,8 @@ class Migration(CheckedMigration): # change, it's completely safe to run the operation after the code has deployed. is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0688_add_project_flag_high_priority_alerts"), ] diff --git a/src/sentry/migrations/0697_remove_monitor_owner_actor_id_db.py b/src/sentry/migrations/0697_remove_monitor_owner_actor_id_db.py index 6f09d09c5c55a..837d74f0dd3f4 100644 --- a/src/sentry/migrations/0697_remove_monitor_owner_actor_id_db.py +++ b/src/sentry/migrations/0697_remove_monitor_owner_actor_id_db.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0696_remove_monitor_owner_actor_id"), ] diff --git a/src/sentry/migrations/0700_drop_fileid_controlavatar.py b/src/sentry/migrations/0700_drop_fileid_controlavatar.py index 0df209ea2d5de..2e0607e567795 100644 --- a/src/sentry/migrations/0700_drop_fileid_controlavatar.py +++ b/src/sentry/migrations/0700_drop_fileid_controlavatar.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0699_update_monitor_owner_team_id_cascsade"), ] diff --git a/src/sentry/migrations/0707_alert_rule_activations_incidents_fk.py b/src/sentry/migrations/0707_alert_rule_activations_incidents_fk.py index ff7a700e1aa93..084f37f473217 100644 --- a/src/sentry/migrations/0707_alert_rule_activations_incidents_fk.py +++ b/src/sentry/migrations/0707_alert_rule_activations_incidents_fk.py @@ -22,6 +22,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0706_grouphistory_userteam_backfill"), ] diff --git a/src/sentry/migrations/0709_alertrule_remove_owner_state.py b/src/sentry/migrations/0709_alertrule_remove_owner_state.py index 4eb13999d671c..8123ffc5f8060 100644 --- a/src/sentry/migrations/0709_alertrule_remove_owner_state.py +++ b/src/sentry/migrations/0709_alertrule_remove_owner_state.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0708_rule_remove_owner_state"), ] diff --git a/src/sentry/migrations/0710_grouphistory_remove_actor_state.py b/src/sentry/migrations/0710_grouphistory_remove_actor_state.py index b011bcbde62c4..59e4bdb580612 100644 --- a/src/sentry/migrations/0710_grouphistory_remove_actor_state.py +++ b/src/sentry/migrations/0710_grouphistory_remove_actor_state.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0709_alertrule_remove_owner_state"), ] diff --git a/src/sentry/migrations/0713_team_remove_actor_state.py b/src/sentry/migrations/0713_team_remove_actor_state.py index 84a80d3fe1d02..f4c773750cfd7 100644 --- a/src/sentry/migrations/0713_team_remove_actor_state.py +++ b/src/sentry/migrations/0713_team_remove_actor_state.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0712_create_tombstone_compound_indexes"), ] diff --git a/src/sentry/migrations/0714_drop_project_team_avatar.py b/src/sentry/migrations/0714_drop_project_team_avatar.py index 73e0438f7c58b..7e3a5b6623364 100644 --- a/src/sentry/migrations/0714_drop_project_team_avatar.py +++ b/src/sentry/migrations/0714_drop_project_team_avatar.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0713_team_remove_actor_state"), ] diff --git a/src/sentry/migrations/0715_remove_actormodel_constraints.py b/src/sentry/migrations/0715_remove_actormodel_constraints.py index cd87515e7ed46..9b9eb125d0a45 100644 --- a/src/sentry/migrations/0715_remove_actormodel_constraints.py +++ b/src/sentry/migrations/0715_remove_actormodel_constraints.py @@ -22,6 +22,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0714_drop_project_team_avatar"), ] diff --git a/src/sentry/migrations/0719_querysubscription_timebox_column_deletion_db.py b/src/sentry/migrations/0719_querysubscription_timebox_column_deletion_db.py index 59ca6933a64ed..718648afa84e1 100644 --- a/src/sentry/migrations/0719_querysubscription_timebox_column_deletion_db.py +++ b/src/sentry/migrations/0719_querysubscription_timebox_column_deletion_db.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0718_delete_timebox_columns"), ] diff --git a/src/sentry/migrations/0720_remove_actor_columns.py b/src/sentry/migrations/0720_remove_actor_columns.py index 6b098b9ebddbc..add6252e7b480 100644 --- a/src/sentry/migrations/0720_remove_actor_columns.py +++ b/src/sentry/migrations/0720_remove_actor_columns.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0719_querysubscription_timebox_column_deletion_db"), ] diff --git a/src/sentry/migrations/0722_drop_sentryfunctions.py b/src/sentry/migrations/0722_drop_sentryfunctions.py index 8e0bcd9ece841..bf0357c3fb98d 100644 --- a/src/sentry/migrations/0722_drop_sentryfunctions.py +++ b/src/sentry/migrations/0722_drop_sentryfunctions.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0721_delete_sentryfunctions"), ] diff --git a/src/sentry/migrations/0724_discover_saved_query_dataset.py b/src/sentry/migrations/0724_discover_saved_query_dataset.py index c8439d7e2261d..0dbf432449a08 100644 --- a/src/sentry/migrations/0724_discover_saved_query_dataset.py +++ b/src/sentry/migrations/0724_discover_saved_query_dataset.py @@ -21,6 +21,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0723_project_template_models"), ] diff --git a/src/sentry/migrations/0725_create_sentry_groupsearchview_table.py b/src/sentry/migrations/0725_create_sentry_groupsearchview_table.py index 40120a0f0db00..eecb7007bcafa 100644 --- a/src/sentry/migrations/0725_create_sentry_groupsearchview_table.py +++ b/src/sentry/migrations/0725_create_sentry_groupsearchview_table.py @@ -26,6 +26,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0724_discover_saved_query_dataset"), ] diff --git a/src/sentry/migrations/0733_relocation_provenance.py b/src/sentry/migrations/0733_relocation_provenance.py index 9600cfa7b7f2c..72626606c5ca6 100644 --- a/src/sentry/migrations/0733_relocation_provenance.py +++ b/src/sentry/migrations/0733_relocation_provenance.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0732_add_span_attribute_extraction_rules"), ] diff --git a/src/sentry/migrations/0737_add_discover_saved_query_dataset_source.py b/src/sentry/migrations/0737_add_discover_saved_query_dataset_source.py index d3d14ff093099..02ea18a44e341 100644 --- a/src/sentry/migrations/0737_add_discover_saved_query_dataset_source.py +++ b/src/sentry/migrations/0737_add_discover_saved_query_dataset_source.py @@ -21,6 +21,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0736_rm_reprocessing_step2"), ] diff --git a/src/sentry/migrations/0738_rm_reprocessing_step3.py b/src/sentry/migrations/0738_rm_reprocessing_step3.py index ed23fac78edb4..de7cde8e7701b 100644 --- a/src/sentry/migrations/0738_rm_reprocessing_step3.py +++ b/src/sentry/migrations/0738_rm_reprocessing_step3.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0737_add_discover_saved_query_dataset_source"), ] diff --git a/src/sentry/migrations/0741_metric_alert_anomaly_detection.py b/src/sentry/migrations/0741_metric_alert_anomaly_detection.py index 3e8d7f3aeda95..86eb1ba26927a 100644 --- a/src/sentry/migrations/0741_metric_alert_anomaly_detection.py +++ b/src/sentry/migrations/0741_metric_alert_anomaly_detection.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0740_one_relocation_file_kind_per_relocation"), ] diff --git a/src/sentry/migrations/0744_add_dataset_source_field_to_dashboards.py b/src/sentry/migrations/0744_add_dataset_source_field_to_dashboards.py index 47159802485e5..de09cf3ff0abe 100644 --- a/src/sentry/migrations/0744_add_dataset_source_field_to_dashboards.py +++ b/src/sentry/migrations/0744_add_dataset_source_field_to_dashboards.py @@ -21,6 +21,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0743_backfill_broken_monitor_notification_setting_option"), ] diff --git a/src/sentry/migrations/0746_add_bitflags_to_hybrid_cloud.py b/src/sentry/migrations/0746_add_bitflags_to_hybrid_cloud.py index 0c577fe5630a9..9dad268ac936f 100644 --- a/src/sentry/migrations/0746_add_bitflags_to_hybrid_cloud.py +++ b/src/sentry/migrations/0746_add_bitflags_to_hybrid_cloud.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0745_add_prevent_superuser_access_bitflag"), ] diff --git a/src/sentry/migrations/0750_disable_member_invite_in_hybrid_cloud.py b/src/sentry/migrations/0750_disable_member_invite_in_hybrid_cloud.py index fcb366e642b1d..3eb750ff9d496 100644 --- a/src/sentry/migrations/0750_disable_member_invite_in_hybrid_cloud.py +++ b/src/sentry/migrations/0750_disable_member_invite_in_hybrid_cloud.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0749_disable_member_invite"), ] diff --git a/src/sentry/migrations/0757_add_scopes_to_apiapplication.py b/src/sentry/migrations/0757_add_scopes_to_apiapplication.py index e0851898bf17a..074c9ce950dc6 100644 --- a/src/sentry/migrations/0757_add_scopes_to_apiapplication.py +++ b/src/sentry/migrations/0757_add_scopes_to_apiapplication.py @@ -21,6 +21,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0756_grouprelease_represented_in_django"), ] diff --git a/src/sentry/migrations/0759_remove_spanattributeextraction_tables.py b/src/sentry/migrations/0759_remove_spanattributeextraction_tables.py index d778dbf7def58..aba74fb7c586e 100644 --- a/src/sentry/migrations/0759_remove_spanattributeextraction_tables.py +++ b/src/sentry/migrations/0759_remove_spanattributeextraction_tables.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0758_remove_spanattributeextraction_models"), ] diff --git a/src/sentry/migrations/0760_remove_appstore_connect_integration_tables.py b/src/sentry/migrations/0760_remove_appstore_connect_integration_tables.py index 3d62e30b52a78..5383ebc03a650 100644 --- a/src/sentry/migrations/0760_remove_appstore_connect_integration_tables.py +++ b/src/sentry/migrations/0760_remove_appstore_connect_integration_tables.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0759_remove_spanattributeextraction_tables"), ] diff --git a/src/sentry/migrations/0776_drop_group_score_in_database.py b/src/sentry/migrations/0776_drop_group_score_in_database.py index 53ed5f75b6f0d..2a9f36dd7e98f 100644 --- a/src/sentry/migrations/0776_drop_group_score_in_database.py +++ b/src/sentry/migrations/0776_drop_group_score_in_database.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = True + allow_run_sql = True + dependencies = [ ("sentry", "0775_add_dashboard_permissions_model"), ] diff --git a/src/sentry/migrations/0785_add_new_field_to_dashboard_permissions.py b/src/sentry/migrations/0785_add_new_field_to_dashboard_permissions.py index 32912ed3a81cf..bae928a544df7 100644 --- a/src/sentry/migrations/0785_add_new_field_to_dashboard_permissions.py +++ b/src/sentry/migrations/0785_add_new_field_to_dashboard_permissions.py @@ -23,6 +23,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0784_remove_broadcasts_cta_column"), ] diff --git a/src/sentry/migrations/0786_drop_broadcasts_cta_column.py b/src/sentry/migrations/0786_drop_broadcasts_cta_column.py index fd14d73769726..c8cac50728a02 100644 --- a/src/sentry/migrations/0786_drop_broadcasts_cta_column.py +++ b/src/sentry/migrations/0786_drop_broadcasts_cta_column.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0785_add_new_field_to_dashboard_permissions"), ] diff --git a/src/sentry/migrations/0790_delete_dashboard_perms_col.py b/src/sentry/migrations/0790_delete_dashboard_perms_col.py index 5349d41fd1470..38e17ab6fda1d 100644 --- a/src/sentry/migrations/0790_delete_dashboard_perms_col.py +++ b/src/sentry/migrations/0790_delete_dashboard_perms_col.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0789_add_unique_constraint_to_rollbackorganization"), ] diff --git a/src/sentry/new_migrations/migrations.py b/src/sentry/new_migrations/migrations.py index ecb9968ebf677..9dc3a5128e280 100644 --- a/src/sentry/new_migrations/migrations.py +++ b/src/sentry/new_migrations/migrations.py @@ -1,4 +1,5 @@ -from django.db.migrations import Migration +from django.db.migrations import Migration, RunSQL +from django_zero_downtime_migrations.backends.postgres.schema import UnsafeOperationException class CheckedMigration(Migration): @@ -16,7 +17,20 @@ class CheckedMigration(Migration): # the `owners-migrations` team. checked = True + # This determines whether we allow `RunSQL` to be used in migrations. We want to discourage this going forward, + # because it's hard for our framework to determine whether SQL is safe. It can also cause problems with setting + # lock/statement timeouts appropriately. + allow_run_sql = False + def apply(self, project_state, schema_editor, collect_sql=False): if self.checked: schema_editor.safe = True + for op in self.operations: + if not self.allow_run_sql and type(op) is RunSQL: + raise UnsafeOperationException( + "Using RunSQL is unsafe because our migrations safety framework can't detect problems with the " + "migration. If you need to use RunSQL, set `allow_run_sql = True` and get approval from " + "`owners-migrations` to make sure that it's safe." + ) + return super().apply(project_state, schema_editor, collect_sql) diff --git a/src/sentry/remote_subscriptions/migrations/0003_drop_remote_subscription.py b/src/sentry/remote_subscriptions/migrations/0003_drop_remote_subscription.py index 650fd61c8b7e0..32b828597f44f 100644 --- a/src/sentry/remote_subscriptions/migrations/0003_drop_remote_subscription.py +++ b/src/sentry/remote_subscriptions/migrations/0003_drop_remote_subscription.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("remote_subscriptions", "0002_remove_separate_remote_subscription"), ("uptime", "0003_drop_remote_subscription"), diff --git a/src/sentry/uptime/migrations/0002_remove_separate_remote_subscription.py b/src/sentry/uptime/migrations/0002_remove_separate_remote_subscription.py index bd79fb509bbbc..cee3dbc032f81 100644 --- a/src/sentry/uptime/migrations/0002_remove_separate_remote_subscription.py +++ b/src/sentry/uptime/migrations/0002_remove_separate_remote_subscription.py @@ -22,6 +22,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("uptime", "0001_uptime_subscriptions"), ("remote_subscriptions", "0001_remote_subscription"), diff --git a/src/sentry/uptime/migrations/0003_drop_remote_subscription.py b/src/sentry/uptime/migrations/0003_drop_remote_subscription.py index 77cf78803a6b1..baaa9f57d0b69 100644 --- a/src/sentry/uptime/migrations/0003_drop_remote_subscription.py +++ b/src/sentry/uptime/migrations/0003_drop_remote_subscription.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("uptime", "0002_remove_separate_remote_subscription"), ] diff --git a/src/sentry/uptime/migrations/0004_projectuptimesubscription_mode.py b/src/sentry/uptime/migrations/0004_projectuptimesubscription_mode.py index 0dec267cd7a3b..7c45752c8c0ea 100644 --- a/src/sentry/uptime/migrations/0004_projectuptimesubscription_mode.py +++ b/src/sentry/uptime/migrations/0004_projectuptimesubscription_mode.py @@ -22,6 +22,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0731_add_insight_project_flags"), ("uptime", "0003_drop_remote_subscription"), diff --git a/src/sentry/uptime/migrations/0005_uptime_status.py b/src/sentry/uptime/migrations/0005_uptime_status.py index b2e5c67d86a5d..5402acf8352eb 100644 --- a/src/sentry/uptime/migrations/0005_uptime_status.py +++ b/src/sentry/uptime/migrations/0005_uptime_status.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("uptime", "0004_projectuptimesubscription_mode"), ] diff --git a/src/sentry/uptime/migrations/0006_projectuptimesubscription_name_owner.py b/src/sentry/uptime/migrations/0006_projectuptimesubscription_name_owner.py index 700265fef0eb7..61a26021ead98 100644 --- a/src/sentry/uptime/migrations/0006_projectuptimesubscription_name_owner.py +++ b/src/sentry/uptime/migrations/0006_projectuptimesubscription_name_owner.py @@ -23,6 +23,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("sentry", "0742_backfill_alertrule_detection_type"), ("uptime", "0005_uptime_status"), diff --git a/src/sentry/uptime/migrations/0008_uptime_url_suffix.py b/src/sentry/uptime/migrations/0008_uptime_url_suffix.py index f1ea789154cca..57ffe779e502e 100644 --- a/src/sentry/uptime/migrations/0008_uptime_url_suffix.py +++ b/src/sentry/uptime/migrations/0008_uptime_url_suffix.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("uptime", "0007_update_detected_subscription_interval"), ] diff --git a/src/sentry/uptime/migrations/0011_remove_uptime_whois_columns_db.py b/src/sentry/uptime/migrations/0011_remove_uptime_whois_columns_db.py index fe4996ed21c1d..529f7f7731c99 100644 --- a/src/sentry/uptime/migrations/0011_remove_uptime_whois_columns_db.py +++ b/src/sentry/uptime/migrations/0011_remove_uptime_whois_columns_db.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("uptime", "0010_remove_uptime_whois_columns_state"), ] diff --git a/src/sentry/uptime/migrations/0012_uptime_subscription_request_fields.py b/src/sentry/uptime/migrations/0012_uptime_subscription_request_fields.py index 87b20132abb29..882fdca1fe915 100644 --- a/src/sentry/uptime/migrations/0012_uptime_subscription_request_fields.py +++ b/src/sentry/uptime/migrations/0012_uptime_subscription_request_fields.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("uptime", "0011_remove_uptime_whois_columns_db"), ] diff --git a/src/sentry/uptime/migrations/0018_add_trace_sampling_field_to_uptime.py b/src/sentry/uptime/migrations/0018_add_trace_sampling_field_to_uptime.py index 84ab364596b37..d16374639f1e4 100644 --- a/src/sentry/uptime/migrations/0018_add_trace_sampling_field_to_uptime.py +++ b/src/sentry/uptime/migrations/0018_add_trace_sampling_field_to_uptime.py @@ -20,6 +20,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("uptime", "0017_unique_on_timeout"), ] diff --git a/src/sentry/workflow_engine/migrations/0010_detector_state_unique_group.py b/src/sentry/workflow_engine/migrations/0010_detector_state_unique_group.py index 51288a9ed8f74..8d5a41873bbe7 100644 --- a/src/sentry/workflow_engine/migrations/0010_detector_state_unique_group.py +++ b/src/sentry/workflow_engine/migrations/0010_detector_state_unique_group.py @@ -21,6 +21,8 @@ class Migration(CheckedMigration): is_post_deployment = False + allow_run_sql = True + dependencies = [ ("workflow_engine", "0009_detector_type"), ] diff --git a/tests/sentry/db/postgres/schema/safe_migrations/integration/test_migrations.py b/tests/sentry/db/postgres/schema/safe_migrations/integration/test_migrations.py index dbbf62b2e187c..80dec14906ed3 100644 --- a/tests/sentry/db/postgres/schema/safe_migrations/integration/test_migrations.py +++ b/tests/sentry/db/postgres/schema/safe_migrations/integration/test_migrations.py @@ -187,6 +187,28 @@ def test(self): self.run_migration() +class RunSqlDisabledTest(BaseSafeMigrationTest): + app = "bad_flow_run_sql_disabled_app" + migrate_from = "0001_initial" + migrate_to = "0001_initial" + + def test(self): + with pytest.raises( + UnsafeOperationException, + match="Using RunSQL is unsafe because our migrations safety framework can't detect problems with the migration.", + ): + self.run_migration() + + +class RunSqlEnabledTest(BaseSafeMigrationTest): + app = "good_flow_run_sql_enabled_app" + migrate_from = "0001_initial" + migrate_to = "0001_initial" + + def test(self): + self.run_migration() + + class DeleteModelCorrectTest(BaseSafeMigrationTest): app = "good_flow_delete_model_state_app" migrate_from = "0001_initial"