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.
This commit is contained in:
Joey Orlando 2024-12-06 13:49:24 -05:00 committed by GitHub
parent e115617528
commit dd2393165d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 81 additions and 23 deletions

View file

@ -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"),
),
]

View file

@ -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"),
),
]

View file

@ -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 @@ import common.migrations.remove_field
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 = [

View file

@ -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',
),
]

View file

@ -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',
),
]

View file

@ -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,