Skip to content

Commit 17fac55

Browse files
committed
chore(migrations): Fix up failed deletes
Deletes were silently failing if `historical_silo_assignments` wasn't updated. We prevent this from happening in #103702, and this cleans up the tables that should have already been removed fix lockfile
1 parent f6bc39b commit 17fac55

File tree

6 files changed

+195
-5
lines changed

6 files changed

+195
-5
lines changed

migrations_lockfile.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ discover: 0003_discover_json_field
99

1010
explore: 0006_add_changed_reason_field_explore
1111

12-
feedback: 0006_safe_del_feedback_model
12+
feedback: 0007_cleanup_failed_safe_deletes
1313

1414
flags: 0001_squashed_0004_add_flag_audit_log_provider_column
1515

@@ -27,16 +27,16 @@ preprod: 0018_add_preprod_artifact_app_icon_id_field
2727

2828
prevent: 0002_alter_integration_id_not_null
2929

30-
releases: 0003_real_delete_dual_written_commit_tables
30+
releases: 0004_cleanup_failed_safe_deletes
3131

3232
replays: 0006_add_bulk_delete_job
3333

34-
sentry: 1006_drop_legacy_incidentseen_incidentsubscription
34+
sentry: 1007_cleanup_failed_safe_deletes
3535

3636
social_auth: 0003_social_auth_json_field
3737

3838
tempest: 0003_use_encrypted_char_field
3939

40-
uptime: 0048_delete_uptime_status_columns
40+
uptime: 0049_cleanup_failed_safe_deletes
4141

42-
workflow_engine: 0101_remove_is_single_written_field
42+
workflow_engine: 0102_cleanup_failed_safe_deletes
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Generated by Django 5.2.8 on 2025-11-19 00:38
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
from sentry.new_migrations.monkey.special import SafeRunSQL
7+
8+
9+
class Migration(CheckedMigration):
10+
# This flag is used to mark that a migration shouldn't be automatically run in production.
11+
# This should only be used for operations where it's safe to run the migration after your
12+
# code has deployed. So this should not be used for most operations that alter the schema
13+
# of a table.
14+
# Here are some things that make sense to mark as post deployment:
15+
# - Large data migrations. Typically we want these to be run manually so that they can be
16+
# monitored and not block the deploy for a long period of time while they run.
17+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
18+
# run this outside deployments so that we don't block them. Note that while adding an index
19+
# is a schema change, it's completely safe to run the operation after the code has deployed.
20+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
21+
22+
is_post_deployment = False
23+
24+
dependencies = [
25+
("feedback", "0006_safe_del_feedback_model"),
26+
]
27+
28+
operations = [
29+
# Clean up table that may not have been deleted due to missing
30+
# historical_silo_assignments entry before the fix
31+
SafeRunSQL(
32+
sql="DROP TABLE IF EXISTS feedback_feedback CASCADE;",
33+
reverse_sql=migrations.RunSQL.noop,
34+
hints={"tables": ["feedback_feedback"]},
35+
),
36+
]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Generated by Django 5.2.8 on 2025-11-19 00:37
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
from sentry.new_migrations.monkey.special import SafeRunSQL
7+
8+
9+
class Migration(CheckedMigration):
10+
# This flag is used to mark that a migration shouldn't be automatically run in production.
11+
# This should only be used for operations where it's safe to run the migration after your
12+
# code has deployed. So this should not be used for most operations that alter the schema
13+
# of a table.
14+
# Here are some things that make sense to mark as post deployment:
15+
# - Large data migrations. Typically we want these to be run manually so that they can be
16+
# monitored and not block the deploy for a long period of time while they run.
17+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
18+
# run this outside deployments so that we don't block them. Note that while adding an index
19+
# is a schema change, it's completely safe to run the operation after the code has deployed.
20+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
21+
22+
is_post_deployment = False
23+
24+
dependencies = [
25+
("sentry", "1006_drop_legacy_incidentseen_incidentsubscription"),
26+
]
27+
28+
operations = [
29+
# Clean up tables that may not have been deleted due to missing
30+
# historical_silo_assignments entries before the fix
31+
SafeRunSQL(
32+
sql="DROP TABLE IF EXISTS sentry_datasecrecywaiver CASCADE;",
33+
reverse_sql=migrations.RunSQL.noop,
34+
hints={"tables": ["sentry_datasecrecywaiver"]},
35+
),
36+
SafeRunSQL(
37+
sql="DROP TABLE IF EXISTS sentry_dashboardwidgetsnapshot CASCADE;",
38+
reverse_sql=migrations.RunSQL.noop,
39+
hints={"tables": ["sentry_dashboardwidgetsnapshot"]},
40+
),
41+
]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Generated by Django 5.2.8 on 2025-11-19 00:38
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
from sentry.new_migrations.monkey.special import SafeRunSQL
7+
8+
9+
class Migration(CheckedMigration):
10+
# This flag is used to mark that a migration shouldn't be automatically run in production.
11+
# This should only be used for operations where it's safe to run the migration after your
12+
# code has deployed. So this should not be used for most operations that alter the schema
13+
# of a table.
14+
# Here are some things that make sense to mark as post deployment:
15+
# - Large data migrations. Typically we want these to be run manually so that they can be
16+
# monitored and not block the deploy for a long period of time while they run.
17+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
18+
# run this outside deployments so that we don't block them. Note that while adding an index
19+
# is a schema change, it's completely safe to run the operation after the code has deployed.
20+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
21+
22+
is_post_deployment = False
23+
24+
dependencies = [
25+
("releases", "0003_real_delete_dual_written_commit_tables"),
26+
]
27+
28+
operations = [
29+
# Clean up tables that may not have been deleted due to missing
30+
# historical_silo_assignments entries before the fix
31+
SafeRunSQL(
32+
sql="DROP TABLE IF EXISTS releases_commit CASCADE;",
33+
reverse_sql=migrations.RunSQL.noop,
34+
hints={"tables": ["releases_commit"]},
35+
),
36+
SafeRunSQL(
37+
sql="DROP TABLE IF EXISTS releases_commitfilechange CASCADE;",
38+
reverse_sql=migrations.RunSQL.noop,
39+
hints={"tables": ["releases_commitfilechange"]},
40+
),
41+
]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Generated by Django 5.2.8 on 2025-11-19 00:38
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
from sentry.new_migrations.monkey.special import SafeRunSQL
7+
8+
9+
class Migration(CheckedMigration):
10+
# This flag is used to mark that a migration shouldn't be automatically run in production.
11+
# This should only be used for operations where it's safe to run the migration after your
12+
# code has deployed. So this should not be used for most operations that alter the schema
13+
# of a table.
14+
# Here are some things that make sense to mark as post deployment:
15+
# - Large data migrations. Typically we want these to be run manually so that they can be
16+
# monitored and not block the deploy for a long period of time while they run.
17+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
18+
# run this outside deployments so that we don't block them. Note that while adding an index
19+
# is a schema change, it's completely safe to run the operation after the code has deployed.
20+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
21+
22+
is_post_deployment = False
23+
24+
dependencies = [
25+
("uptime", "0048_delete_uptime_status_columns"),
26+
]
27+
28+
operations = [
29+
# Clean up table that may not have been deleted due to missing
30+
# historical_silo_assignments entry before the fix
31+
SafeRunSQL(
32+
sql="DROP TABLE IF EXISTS uptime_projectuptimesubscription CASCADE;",
33+
reverse_sql=migrations.RunSQL.noop,
34+
hints={"tables": ["uptime_projectuptimesubscription"]},
35+
),
36+
]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Generated by Django 5.2.8 on 2025-11-19 00:38
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
from sentry.new_migrations.monkey.special import SafeRunSQL
7+
8+
9+
class Migration(CheckedMigration):
10+
# This flag is used to mark that a migration shouldn't be automatically run in production.
11+
# This should only be used for operations where it's safe to run the migration after your
12+
# code has deployed. So this should not be used for most operations that alter the schema
13+
# of a table.
14+
# Here are some things that make sense to mark as post deployment:
15+
# - Large data migrations. Typically we want these to be run manually so that they can be
16+
# monitored and not block the deploy for a long period of time while they run.
17+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
18+
# run this outside deployments so that we don't block them. Note that while adding an index
19+
# is a schema change, it's completely safe to run the operation after the code has deployed.
20+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
21+
22+
is_post_deployment = False
23+
24+
dependencies = [
25+
("workflow_engine", "0101_remove_is_single_written_field"),
26+
]
27+
28+
operations = [
29+
# Clean up table that may not have been deleted due to missing
30+
# historical_silo_assignments entry before the fix
31+
SafeRunSQL(
32+
sql="DROP TABLE IF EXISTS workflow_engine_actiongroupstatus CASCADE;",
33+
reverse_sql=migrations.RunSQL.noop,
34+
hints={"tables": ["workflow_engine_actiongroupstatus"]},
35+
),
36+
]

0 commit comments

Comments
 (0)