Skip to content

Commit 4c748c7

Browse files
Merge branch 'master' into athena/add-scoping-org-to-all
2 parents ceaf648 + 09d8917 commit 4c748c7

File tree

136 files changed

+1549
-319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1549
-319
lines changed

fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by Django 3.1 on 2019-09-22 21:47
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
7+
8+
class Migration(CheckedMigration):
9+
10+
initial = True
11+
12+
dependencies = []
13+
14+
allow_run_sql = False
15+
16+
operations = [migrations.RunSQL("select 1;")]

fixtures/safe_migrations_apps/bad_flow_run_sql_disabled_app/migrations/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.db import models
2+
3+
4+
class TestTable(models.Model):
5+
field = models.IntegerField(default=0, null=False)

fixtures/safe_migrations_apps/good_flow_delete_field_pending_with_not_null_m2m_app/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from django.db import migrations, models
2+
3+
from sentry.db.models import FlexibleForeignKey
4+
from sentry.new_migrations.migrations import CheckedMigration
5+
6+
7+
class Migration(CheckedMigration):
8+
9+
initial = True
10+
checked = False
11+
12+
dependencies = []
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name="OtherTable",
17+
fields=[
18+
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False)),
19+
],
20+
),
21+
migrations.CreateModel(
22+
name="M2MTable",
23+
fields=[
24+
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False)),
25+
(
26+
"alert_rule",
27+
FlexibleForeignKey(
28+
on_delete=models.deletion.CASCADE,
29+
to="good_flow_delete_field_pending_with_not_null_m2m_app.othertable",
30+
),
31+
),
32+
],
33+
),
34+
migrations.CreateModel(
35+
name="TestTable",
36+
fields=[
37+
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False)),
38+
(
39+
"excluded_projects",
40+
models.ManyToManyField(
41+
through="good_flow_delete_field_pending_with_not_null_m2m_app.M2MTable",
42+
to="good_flow_delete_field_pending_with_not_null_m2m_app.othertable",
43+
),
44+
),
45+
],
46+
),
47+
migrations.AddField(
48+
model_name="m2mtable",
49+
name="test_table",
50+
field=FlexibleForeignKey(
51+
on_delete=models.deletion.CASCADE,
52+
to="good_flow_delete_field_pending_with_not_null_m2m_app.testtable",
53+
),
54+
),
55+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from sentry.new_migrations.migrations import CheckedMigration
2+
from sentry.new_migrations.monkey.fields import SafeRemoveField
3+
from sentry.new_migrations.monkey.state import DeletionAction
4+
5+
6+
class Migration(CheckedMigration):
7+
dependencies = [
8+
("good_flow_delete_field_pending_with_not_null_m2m_app", "0001_initial"),
9+
]
10+
11+
operations = [
12+
SafeRemoveField(
13+
model_name="testtable",
14+
name="excluded_projects",
15+
deletion_action=DeletionAction.MOVE_TO_PENDING,
16+
),
17+
]

fixtures/safe_migrations_apps/good_flow_delete_field_pending_with_not_null_m2m_app/migrations/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from django.db import models
2+
3+
from sentry.db.models import FlexibleForeignKey
4+
5+
6+
class OtherTable(models.Model):
7+
pass
8+
9+
10+
class M2MTable(models.Model):
11+
alert_rule = FlexibleForeignKey(OtherTable)
12+
test_table = FlexibleForeignKey(
13+
"good_flow_delete_field_pending_with_not_null_m2m_app.TestTable"
14+
)
15+
16+
17+
class TestTable(models.Model):
18+
excluded_projects = models.ManyToManyField(OtherTable, through=M2MTable)
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Generated by Django 3.1 on 2019-09-22 21:47
2-
3-
from django.db import migrations
4-
52
from sentry.new_migrations.migrations import CheckedMigration
3+
from sentry.new_migrations.monkey.models import SafeDeleteModel
4+
from sentry.new_migrations.monkey.state import DeletionAction
65

76

87
class Migration(CheckedMigration):
@@ -12,11 +11,5 @@ class Migration(CheckedMigration):
1211
]
1312

1413
operations = [
15-
migrations.SeparateDatabaseAndState(
16-
state_operations=[
17-
migrations.DeleteModel(
18-
name="TestTable",
19-
),
20-
]
21-
)
14+
SafeDeleteModel(name="TestTable", deletion_action=DeletionAction.MOVE_TO_PENDING),
2215
]
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# Generated by Django 3.1 on 2019-09-22 21:47
2-
3-
from django.db import migrations
4-
52
from sentry.new_migrations.migrations import CheckedMigration
3+
from sentry.new_migrations.monkey.models import SafeDeleteModel
4+
from sentry.new_migrations.monkey.state import DeletionAction
65

76

87
class Migration(CheckedMigration):
98

109
dependencies = [
11-
("good_flow_delete_model_state_app", "0001_initial"),
10+
("good_flow_delete_model_state_app", "0002_delete_model_state"),
1211
]
1312

1413
operations = [
15-
migrations.RunSQL('DROP TABLE "good_flow_delete_model_state_app_testtable";'),
14+
SafeDeleteModel(name="TestTable", deletion_action=DeletionAction.DELETE),
1615
]

fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by Django 3.1 on 2019-09-22 21:47
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
7+
8+
class Migration(CheckedMigration):
9+
10+
initial = True
11+
12+
dependencies = []
13+
14+
allow_run_sql = True
15+
16+
operations = [migrations.RunSQL("select 1;")]

fixtures/safe_migrations_apps/good_flow_run_sql_enabled_app/migrations/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.db import models
2+
3+
4+
class TestTable(models.Model):
5+
field = models.IntegerField(default=0, null=False)

src/sentry/api/urls.py

+2
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@
337337
from sentry.users.api.endpoints.user_roles import UserUserRolesEndpoint
338338
from sentry.users.api.endpoints.userroles_details import UserRoleDetailsEndpoint
339339
from sentry.users.api.endpoints.userroles_index import UserRolesEndpoint
340+
from sentry.workflow_engine.endpoints import urls as workflow_urls
340341

341342
from .endpoints.accept_organization_invite import AcceptOrganizationInvite
342343
from .endpoints.accept_project_transfer import AcceptProjectTransferEndpoint
@@ -2794,6 +2795,7 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]:
27942795
ProjectUptimeAlertIndexEndpoint.as_view(),
27952796
name="sentry-api-0-project-uptime-alert-index",
27962797
),
2798+
*workflow_urls.urlpatterns,
27972799
]
27982800

27992801
TEAM_URLS = [

src/sentry/hybridcloud/migrations/0003_add_scopes_to_api_key_replica.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Migration(CheckedMigration):
2020
# change, it's completely safe to run the operation after the code has deployed.
2121
is_post_deployment = False
2222

23+
allow_run_sql = True
24+
2325
dependencies = [
2426
("hybridcloud", "0002_add_slug_reservation_replica_model"),
2527
]

src/sentry/ingest/consumer/processors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ def process_event(
203203
else:
204204
with metrics.timer("ingest_consumer._store_event"):
205205
cache_key = processing_store.store(data)
206-
if data.get("type") == "transaction":
206+
if consumer_type == ConsumerType.Transactions:
207207
track_sampled_event(
208-
data["event_id"], "transaction", TransactionStageStatus.REDIS_PUT
208+
data["event_id"], ConsumerType.Transactions, TransactionStageStatus.REDIS_PUT
209209
)
210210

211211
save_attachments(attachments, cache_key)

src/sentry/ingest/types.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class ConsumerType:
1+
from enum import StrEnum
2+
3+
4+
class ConsumerType(StrEnum):
25
"""
36
Defines the types of ingestion consumers
47
"""

src/sentry/integrations/discord/actions/metric_alert.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def send_incident_alert_notification(
3838
# We can't send a message if we don't know the channel
3939
logger.warning(
4040
"discord.metric_alert.no_channel",
41-
extra={"guild_id": incident.identifier},
41+
extra={"incident_id": incident.id},
4242
)
4343
return False
4444

@@ -56,7 +56,7 @@ def send_incident_alert_notification(
5656
except Exception as error:
5757
logger.warning(
5858
"discord.metric_alert.message_send_failure",
59-
extra={"error": error, "guild_id": incident.identifier, "channel_id": channel},
59+
extra={"error": error, "incident_id": incident.id, "channel_id": channel},
6060
)
6161
return False
6262
else:

src/sentry/migrations/0001_squashed_0484_break_org_member_user_fk.py

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class Migration(CheckedMigration):
5454
# change, it's completely safe to run the operation after the code has deployed.
5555
is_post_deployment = False
5656

57+
allow_run_sql = True
58+
5759
replaces = [
5860
("sentry", "0001_squashed_0200_release_indices"),
5961
("sentry", "0201_semver_package"),

src/sentry/migrations/0490_add_is_test_to_org.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Migration(CheckedMigration):
1818
# change, it's completely safe to run the operation after the code has deployed.
1919
is_post_deployment = False
2020

21+
allow_run_sql = True
22+
2123
dependencies = [
2224
("sentry", "0489_index_checkin_timeout"),
2325
]

src/sentry/migrations/0491_remove_orgmemmap_unique_constraints.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Migration(CheckedMigration):
1818
# change, it's completely safe to run the operation after the code has deployed.
1919
is_post_deployment = False
2020

21+
allow_run_sql = True
22+
2123
dependencies = [
2224
("sentry", "0490_add_is_test_to_org"),
2325
]

src/sentry/migrations/0505_debugfile_date_accessed.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Migration(CheckedMigration):
1919
# change, it's completely safe to run the operation after the code has deployed.
2020
is_post_deployment = False
2121

22+
allow_run_sql = True
23+
2224
dependencies = [
2325
("sentry", "0504_add_artifact_bundle_index"),
2426
]

src/sentry/migrations/0526_pr_comment_type_column.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class Migration(CheckedMigration):
2121
# change, it's completely safe to run the operation after the code has deployed.
2222
is_post_deployment = False
2323

24+
allow_run_sql = True
25+
2426
dependencies = [
2527
("sentry", "0525_add_next_checkin_latest"),
2628
]

src/sentry/migrations/0535_add_created_date_to_outbox_model.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Migration(CheckedMigration):
1919
# change, it's completely safe to run the operation after the code has deployed.
2020
is_post_deployment = False
2121

22+
allow_run_sql = True
23+
2224
dependencies = [
2325
("sentry", "0534_add_notification_uuid_to_rule_fire_history"),
2426
]

src/sentry/migrations/0544_remove_groupsubscription_columns.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Migration(CheckedMigration):
1818
# change, it's completely safe to run the operation after the code has deployed.
1919
is_post_deployment = False
2020

21+
allow_run_sql = True
22+
2123
dependencies = [
2224
("sentry", "0543_add_team_id_to_groupsubscription"),
2325
]

src/sentry/migrations/0545_add_last_verified_auth_ident_replica.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Migration(CheckedMigration):
1919
# change, it's completely safe to run the operation after the code has deployed.
2020
is_post_deployment = False
2121

22+
allow_run_sql = True
23+
2224
dependencies = [
2325
("sentry", "0544_remove_groupsubscription_columns"),
2426
]

src/sentry/migrations/0548_add_is_unclaimed_boolean_to_user.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Migration(CheckedMigration):
1818
# change, it's completely safe to run the operation after the code has deployed.
1919
is_post_deployment = False
2020

21+
allow_run_sql = True
22+
2123
dependencies = [
2224
("sentry", "0547_add_commitfilechange_language_column"),
2325
]

src/sentry/migrations/0549_re_add_groupsubscription_columns.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Migration(CheckedMigration):
2020
# change, it's completely safe to run the operation after the code has deployed.
2121
is_post_deployment = True
2222

23+
allow_run_sql = True
24+
2325
dependencies = [
2426
("sentry", "0548_add_is_unclaimed_boolean_to_user"),
2527
]

src/sentry/migrations/0556_organizationmapping_replicate_require_2fa.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Migration(CheckedMigration):
1818
# change, it's completely safe to run the operation after the code has deployed.
1919
is_post_deployment = False
2020

21+
allow_run_sql = True
22+
2123
dependencies = [
2224
("sentry", "0555_set_neglectedrule_email_date_columns_nullable"),
2325
]

src/sentry/migrations/0564_commitfilechange_delete_language_column.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Migration(CheckedMigration):
1818
# change, it's completely safe to run the operation after the code has deployed.
1919
is_post_deployment = False
2020

21+
allow_run_sql = True
22+
2123
dependencies = [
2224
("sentry", "0563_commitfilechange_drop_language_column"),
2325
]

src/sentry/migrations/0570_repository_add_languages_column.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Migration(CheckedMigration):
1919
# change, it's completely safe to run the operation after the code has deployed.
2020
is_post_deployment = False
2121

22+
allow_run_sql = True
23+
2224
dependencies = [
2325
("sentry", "0569_dashboard_widgets_indicator"),
2426
]

src/sentry/migrations/0583_add_early_adopter_to_organization_mapping.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Migration(CheckedMigration):
1818
# change, it's completely safe to run the operation after the code has deployed.
1919
is_post_deployment = False
2020

21+
allow_run_sql = True
22+
2123
dependencies = [
2224
("sentry", "0582_add_status_indexes_checkins"),
2325
]

src/sentry/migrations/0590_add_metadata_to_sentry_app.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Migration(CheckedMigration):
1919
# change, it's completely safe to run the operation after the code has deployed.
2020
is_post_deployment = False
2121

22+
allow_run_sql = True
23+
2224
dependencies = [
2325
("sentry", "0589_add_commit_date_added_indices"),
2426
]

src/sentry/migrations/0591_remove_relocation_hybrid_cloud_foreign_keys.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Migration(CheckedMigration):
1919
# change, it's completely safe to run the operation after the code has deployed.
2020
is_post_deployment = False
2121

22+
allow_run_sql = True
23+
2224
dependencies = [
2325
("sentry", "0590_add_metadata_to_sentry_app"),
2426
]

0 commit comments

Comments
 (0)