From dd2393165d3de4c3490f644c6bb009a59a098696 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Fri, 6 Dec 2024 13:49:24 -0500 Subject: [PATCH] chore: remove `SlackMessage._channel_id` and `SlackMessage.organization` fields (#5340) # What this PR does Follow-up cleanup PR for https://github.com/grafana/oncall/pull/5325 (and https://github.com/grafana/oncall/pull/5330) ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes. --- ...0013_remove_slackmessage__channel_id_db.py | 22 +++++++++++++++++++ ...014_remove_slackmessage_organization_db.py | 22 +++++++++++++++++++ ..._slackmessage_active_update_task_id_db.py} | 5 +---- ...1_remove_slackmessage__channel_id_state.py | 18 +++++++++++++++ ..._remove_slackmessage_organization_state.py | 18 +++++++++++++++ engine/apps/slack/models/slack_message.py | 19 ---------------- 6 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 engine/apps/slack/0013_remove_slackmessage__channel_id_db.py create mode 100644 engine/apps/slack/0014_remove_slackmessage_organization_db.py rename engine/apps/slack/{0009_remove_slackmessage_active_update_task_id_db.py => migrations/0010_remove_slackmessage_active_update_task_id_db.py} (69%) create mode 100644 engine/apps/slack/migrations/0011_remove_slackmessage__channel_id_state.py create mode 100644 engine/apps/slack/migrations/0012_remove_slackmessage_organization_state.py diff --git a/engine/apps/slack/0013_remove_slackmessage__channel_id_db.py b/engine/apps/slack/0013_remove_slackmessage__channel_id_db.py new file mode 100644 index 000000000..033e06a0f --- /dev/null +++ b/engine/apps/slack/0013_remove_slackmessage__channel_id_db.py @@ -0,0 +1,22 @@ +# NOTE: this is being left in this directory on purpose, it will be moved to apps/alerts/migrations +# in a separate PR/release +# +# Generated by Django 4.2.17 on 2024-12-06 17:05 + +from django.db import migrations + +import common.migrations.remove_field + + +class Migration(migrations.Migration): + dependencies = [ + ("slack", "0012_remove_slackmessage_organization_state"), + ] + + operations = [ + common.migrations.remove_field.RemoveFieldDB( + model_name="SlackMessage", + name="_channel_id", + remove_state_migration=("slack", "0011_remove_slackmessage__channel_id_state"), + ), + ] diff --git a/engine/apps/slack/0014_remove_slackmessage_organization_db.py b/engine/apps/slack/0014_remove_slackmessage_organization_db.py new file mode 100644 index 000000000..e95de423f --- /dev/null +++ b/engine/apps/slack/0014_remove_slackmessage_organization_db.py @@ -0,0 +1,22 @@ +# NOTE: this is being left in this directory on purpose, it will be moved to apps/alerts/migrations +# in a separate PR/release +# +# Generated by Django 4.2.17 on 2024-12-06 17:05 + +from django.db import migrations + +import common.migrations.remove_field + + +class Migration(migrations.Migration): + dependencies = [ + ("slack", "0013_remove_slackmessage__channel_id_db"), + ] + + operations = [ + common.migrations.remove_field.RemoveFieldDB( + model_name="SlackMessage", + name="organization", + remove_state_migration=("slack", "0012_remove_slackmessage_organization_state"), + ), + ] diff --git a/engine/apps/slack/0009_remove_slackmessage_active_update_task_id_db.py b/engine/apps/slack/migrations/0010_remove_slackmessage_active_update_task_id_db.py similarity index 69% rename from engine/apps/slack/0009_remove_slackmessage_active_update_task_id_db.py rename to engine/apps/slack/migrations/0010_remove_slackmessage_active_update_task_id_db.py index 15617dfda..7b81492b3 100644 --- a/engine/apps/slack/0009_remove_slackmessage_active_update_task_id_db.py +++ b/engine/apps/slack/migrations/0010_remove_slackmessage_active_update_task_id_db.py @@ -1,6 +1,3 @@ -# NOTE: this is being left in this directory on purpose, it will be moved to apps/alerts/migrations -# in a separate PR/release -# # Generated by Django 4.2.16 on 2024-12-04 12:00 from django.db import migrations @@ -10,7 +7,7 @@ class Migration(migrations.Migration): dependencies = [ - ("slack", "0008_remove_slackmessage_active_update_task_id_state"), + ("slack", "0009_drop_orphaned_messages_and_fill_in_missing_team_identity_values"), ] operations = [ diff --git a/engine/apps/slack/migrations/0011_remove_slackmessage__channel_id_state.py b/engine/apps/slack/migrations/0011_remove_slackmessage__channel_id_state.py new file mode 100644 index 000000000..886f8b603 --- /dev/null +++ b/engine/apps/slack/migrations/0011_remove_slackmessage__channel_id_state.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.17 on 2024-12-06 17:05 + +import common.migrations.remove_field +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('slack', '0010_remove_slackmessage_active_update_task_id_db'), + ] + + operations = [ + common.migrations.remove_field.RemoveFieldState( + model_name='SlackMessage', + name='_channel_id', + ), + ] diff --git a/engine/apps/slack/migrations/0012_remove_slackmessage_organization_state.py b/engine/apps/slack/migrations/0012_remove_slackmessage_organization_state.py new file mode 100644 index 000000000..5d8404ec5 --- /dev/null +++ b/engine/apps/slack/migrations/0012_remove_slackmessage_organization_state.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.17 on 2024-12-06 17:05 + +import common.migrations.remove_field +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('slack', '0011_remove_slackmessage__channel_id_state'), + ] + + operations = [ + common.migrations.remove_field.RemoveFieldState( + model_name='SlackMessage', + name='organization', + ), + ] diff --git a/engine/apps/slack/models/slack_message.py b/engine/apps/slack/models/slack_message.py index 16b032e2a..73fbf5b4c 100644 --- a/engine/apps/slack/models/slack_message.py +++ b/engine/apps/slack/models/slack_message.py @@ -39,11 +39,6 @@ class SlackMessage(models.Model): id = models.CharField(primary_key=True, default=uuid.uuid4, editable=False, max_length=36) slack_id = models.CharField(max_length=100) - _channel_id = models.CharField(max_length=100, null=True, default=None) - """ - DEPRECATED/TODO: this is no longer being referenced/set, drop in a separate PR/release - """ - channel = models.ForeignKey( "slack.SlackChannel", on_delete=models.CASCADE, null=True, default=None, related_name="slack_messages" ) @@ -52,20 +47,6 @@ class SlackMessage(models.Model): (a slack message always needs to have a slack channel associated with it) """ - organization = models.ForeignKey( - "user_management.Organization", - on_delete=models.CASCADE, - null=True, - default=None, - related_name="slack_message", - ) - """ - DEPRECATED/TODO: drop this field in a separate PR/release - - For alert group related slack messages, we can always get the organization from the alert_group.channel - For shift swap request related slack messages, the schedule has a reference to the organization - """ - _slack_team_identity = models.ForeignKey( "slack.SlackTeamIdentity", on_delete=models.PROTECT,