-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore(aci): make DetectorGroup unique on Group #102928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Generated by Django 5.2.1 on 2025-11-06 22:43 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.db import migrations | ||
|
|
||
| import sentry.db.models.fields.foreignkey | ||
| from sentry.new_migrations.migrations import CheckedMigration | ||
|
|
||
|
|
||
| class Migration(CheckedMigration): | ||
| # This flag is used to mark that a migration shouldn't be automatically run in production. | ||
| # This should only be used for operations where it's safe to run the migration after your | ||
| # code has deployed. So this should not be used for most operations that alter the schema | ||
| # of a table. | ||
| # Here are some things that make sense to mark as post deployment: | ||
| # - Large data migrations. Typically we want these to be run manually so that they can be | ||
| # monitored and not block the deploy for a long period of time while they run. | ||
| # - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to | ||
| # run this outside deployments so that we don't block them. Note that while adding an index | ||
| # is a schema change, it's completely safe to run the operation after the code has deployed. | ||
| # Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment | ||
|
|
||
| is_post_deployment = True | ||
|
|
||
| dependencies = [ | ||
| ("sentry", "1003_group_history_prev_history_safe_removal"), | ||
| ("workflow_engine", "0094_backfill_issue_stream_detector_workflows"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name="detectorgroup", | ||
| name="group", | ||
| field=sentry.db.models.fields.foreignkey.FlexibleForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, to="sentry.group", unique=True | ||
| ), | ||
| ), | ||
| migrations.AlterUniqueTogether( | ||
| name="detectorgroup", | ||
| unique_together=set(), | ||
| ), | ||
cathteng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ] | ||
cathteng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,12 +13,11 @@ class DetectorGroup(DefaultFieldsModel): | |
| __relocation_scope__ = RelocationScope.Excluded | ||
|
|
||
| detector = FlexibleForeignKey("workflow_engine.Detector", on_delete=models.CASCADE) | ||
| group = FlexibleForeignKey("sentry.Group", on_delete=models.CASCADE) | ||
| group = FlexibleForeignKey("sentry.Group", on_delete=models.CASCADE, unique=True) | ||
|
|
||
| class Meta: | ||
| db_table = "workflow_engine_detectorgroup" | ||
| app_label = "workflow_engine" | ||
| unique_together = (("detector", "group"),) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we're safe enough without this index. If we search on |
||
| indexes = [ | ||
| models.Index(fields=["detector", "-date_added"], name="detectorgroup_det_date_idx"), | ||
| ] | ||
Uh oh!
There was an error while loading. Please reload this page.