From 88070acf132434b4550a2e4fa715ddbd0f27d5b4 Mon Sep 17 00:00:00 2001 From: Cathy Teng Date: Tue, 3 Dec 2024 10:45:40 -0800 Subject: [PATCH] migration changes --- migrations_lockfile.txt | 2 +- .../0015_workflow_engine_changes.py | 33 +++++++++++++++++++ src/sentry/workflow_engine/models/workflow.py | 4 +++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/sentry/workflow_engine/migrations/0015_workflow_engine_changes.py diff --git a/migrations_lockfile.txt b/migrations_lockfile.txt index 12164df5ebdb2b..c8ae6a8c41df09 100644 --- a/migrations_lockfile.txt +++ b/migrations_lockfile.txt @@ -21,4 +21,4 @@ social_auth: 0002_default_auto_field uptime: 0018_add_trace_sampling_field_to_uptime -workflow_engine: 0014_model_additions_for_milestones +workflow_engine: 0015_workflow_engine_changes diff --git a/src/sentry/workflow_engine/migrations/0015_workflow_engine_changes.py b/src/sentry/workflow_engine/migrations/0015_workflow_engine_changes.py new file mode 100644 index 00000000000000..c6e77f15774d14 --- /dev/null +++ b/src/sentry/workflow_engine/migrations/0015_workflow_engine_changes.py @@ -0,0 +1,33 @@ +# Generated by Django 5.1.1 on 2024-12-03 18:45 + +from django.db import migrations, models + +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 = False + + dependencies = [ + ("workflow_engine", "0014_model_additions_for_milestones"), + ] + + operations = [ + migrations.AddField( + model_name="workflow", + name="frequency", + field=models.IntegerField(default=30), + ), + ] diff --git a/src/sentry/workflow_engine/models/workflow.py b/src/sentry/workflow_engine/models/workflow.py index d2f6e5fd5f0e01..9e3b1a4aeb961d 100644 --- a/src/sentry/workflow_engine/models/workflow.py +++ b/src/sentry/workflow_engine/models/workflow.py @@ -18,6 +18,8 @@ class Workflow(DefaultFieldsModel, OwnerModel, JSONConfigBase): Workflows are initiated after detectors have been processed, driven by changes to their state. """ + DEFAULT_FREQUENCY = 30 # minutes + __relocation_scope__ = RelocationScope.Organization name = models.CharField(max_length=200) organization = FlexibleForeignKey("sentry.Organization") @@ -32,6 +34,8 @@ class Workflow(DefaultFieldsModel, OwnerModel, JSONConfigBase): created_by_id = HybridCloudForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete="SET_NULL") + frequency = models.IntegerField(default=DEFAULT_FREQUENCY) + @property def CONFIG_SCHEMA(self) -> dict[str, Any]: raise NotImplementedError('Subclasses must define a "CONFIG_SCHEMA" attribute')