-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
ref(seer onboarding): remove on_command_phrase CR trigger from repo settings and org options #105978
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
ref(seer onboarding): remove on_command_phrase CR trigger from repo settings and org options #105978
Changes from all commits
dea835f
639391a
2332ff1
628c7fa
411a245
6e410ee
286fc40
bd700ff
25d7dfd
7970184
69fa5de
363f975
8a5d0c0
4066ced
e726f5c
a3886f1
cac411c
ac0aa40
1732776
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,76 @@ | ||
| # Generated by Django 5.2.8 on 2026-01-08 18:18 | ||
|
|
||
| import django.contrib.postgres.fields | ||
| from django.db import migrations, models | ||
| from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
| from django.db.migrations.state import StateApps | ||
|
|
||
| from sentry.new_migrations.migrations import CheckedMigration | ||
|
|
||
|
|
||
| def remove_on_command_phrase_from_repository_settings( | ||
| apps: StateApps, schema_editor: BaseDatabaseSchemaEditor | ||
| ) -> None: | ||
| """Remove 'on_command_phrase' from RepositorySettings.code_review_triggers.""" | ||
| RepositorySettings = apps.get_model("sentry", "RepositorySettings") | ||
|
|
||
| all_settings = list(RepositorySettings.objects.all()) | ||
|
|
||
| updated_settings = [] | ||
| for settings in all_settings: | ||
| if ( | ||
| settings.code_review_triggers | ||
| and isinstance(settings.code_review_triggers, list) | ||
| and "on_command_phrase" in settings.code_review_triggers | ||
| ): | ||
| settings.code_review_triggers = [ | ||
| trigger | ||
| for trigger in settings.code_review_triggers | ||
| if trigger != "on_command_phrase" | ||
| ] | ||
| updated_settings.append(settings) | ||
|
|
||
| if updated_settings: | ||
| RepositorySettings.objects.bulk_update(updated_settings, fields=["code_review_triggers"]) | ||
srest2021 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| 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 = False | ||
|
|
||
| dependencies = [ | ||
| ("sentry", "1015_backfill_self_hosted_sentry_app_emails"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython( | ||
| remove_on_command_phrase_from_repository_settings, | ||
| reverse_code=migrations.RunPython.noop, | ||
| hints={"tables": ["sentry_repositorysettings"]}, | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="repositorysettings", | ||
| name="code_review_triggers", | ||
| field=django.contrib.postgres.fields.ArrayField( | ||
| base_field=models.CharField( | ||
| choices=[ | ||
| ("on_new_commit", "on_new_commit"), | ||
| ("on_ready_for_review", "on_ready_for_review"), | ||
| ], | ||
| max_length=32, | ||
| ), | ||
| default=list, | ||
| ), | ||
| ), | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ | |
|
|
||
|
|
||
| class CodeReviewTrigger(StrEnum): | ||
| ON_COMMAND_PHRASE = "on_command_phrase" | ||
|
Contributor
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. Uncleaned org options can propagate invalid triggers to new reposLow Severity The migration removes Additional Locations (1)
Member
Author
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. |
||
| ON_NEW_COMMIT = "on_new_commit" | ||
| ON_READY_FOR_REVIEW = "on_ready_for_review" | ||
|
|
||
srest2021 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| from sentry.models.repositorysettings import RepositorySettings | ||
| from sentry.testutils.cases import TestMigrations | ||
|
|
||
|
|
||
| class RemoveOnCommandPhraseTriggerTest(TestMigrations): | ||
| migrate_from = "1015_backfill_self_hosted_sentry_app_emails" | ||
| migrate_to = "1016_remove_on_command_phrase_trigger" | ||
|
|
||
| def setup_initial_state(self) -> None: | ||
| org = self.create_organization() | ||
| self.project1 = self.create_project(organization=org) | ||
| self.repo1 = self.create_repo(project=self.project1, name="org/repo1") | ||
| self.repo_settings1 = RepositorySettings.objects.create( | ||
| repository=self.repo1, | ||
| enabled_code_review=True, | ||
| code_review_triggers=["on_command_phrase", "on_ready_for_review", "on_new_commit"], | ||
| ) | ||
|
|
||
| self.project2 = self.create_project(organization=org) | ||
| self.repo2 = self.create_repo(project=self.project2, name="org/repo2") | ||
| self.repo_settings2 = RepositorySettings.objects.create( | ||
| repository=self.repo2, | ||
| enabled_code_review=True, | ||
| code_review_triggers=["on_ready_for_review", "on_new_commit"], | ||
| ) | ||
|
|
||
| self.project3 = self.create_project(organization=org) | ||
| self.repo3 = self.create_repo(project=self.project3, name="org/repo3") | ||
| self.repo_settings3 = RepositorySettings.objects.create( | ||
| repository=self.repo3, enabled_code_review=True | ||
| ) | ||
|
|
||
| def test(self) -> None: | ||
| repo_settings = RepositorySettings.objects.get(id=self.repo_settings1.id) | ||
| assert repo_settings.code_review_triggers == ["on_ready_for_review", "on_new_commit"] | ||
| assert "on_command_phrase" not in repo_settings.code_review_triggers | ||
|
|
||
| repo_settings = RepositorySettings.objects.get(id=self.repo_settings2.id) | ||
| assert repo_settings.code_review_triggers == ["on_ready_for_review", "on_new_commit"] | ||
| assert "on_command_phrase" not in repo_settings.code_review_triggers | ||
|
|
||
| repo_settings = RepositorySettings.objects.get(id=self.repo_settings3.id) | ||
| assert repo_settings.code_review_triggers == [] |


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This table is less than 200 rows, so should be safe to skip doing it post-deployment.