oncall-engine/engine/apps/user_management
Joey Orlando a29e35c25a
refactor SlackMessage.channel_id (CHAR field) to SlackMessage.channel (foreign key relationship) (#5292)
# What this PR does

Related to https://github.com/grafana/oncall-private/issues/2947

**NOTE**

This PR introduces steps 1 and 2 of the 3 part migration proposed
[here](https://raintank-corp.slack.com/archives/C06K1MQ07GS/p1732555465144099).
Step 3, swapping reads to be from the new-column and dropping
dual-writes, will be done in a future PR/release.

---

I’m tackling this work now because _ultimately_ I want to move
`AlertReceiveChannel.rate_limited_in_slack_at` to
`SlackChannel.rate_limited_at` , but first I sorta need to refactor
`SlackMessage.channel_id` from a `CHAR` field to a foreign key
relationship (because in the spots where we touch Slack rate limiting,
like
[here](https://github.com/grafana/oncall/blob/dev/engine/apps/slack/alert_group_slack_service.py#L42-L50)
for example, we only have `slack_message.channel_id`, which means I need
to do extra queries to fetch the appropriate `SlackChannel` to then be
able to get/set `SlackChannel.rate_limited_at`

Other minor stuffs:
- it also prepares us to drop `SlackMessage._slack_team_identity`. We
already have a `@property` of `SlackMessage.slack_team_identity` (which
[previously had some hacky
logic](https://github.com/grafana/oncall/blob/dev/engine/apps/slack/models/slack_message.py#L74-L84)).
I've refactored `SlackMessage.slack_team_identity` to simply point to
`self.organization.slack_team_identity` + updated our code to _stop_
setting `SlackMessage._slack_team_identity` (will drop this column in
future release)

## 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.
2024-11-26 11:03:38 +00:00
..
migrations chore: finish drop columns migrations (#5280) 2024-11-21 03:29:51 -05:00
models chore: remove deprecated AlertGroupPostMortem model + recently refactored/deprecated slack channel related columns (#5240) 2024-11-19 19:23:48 +00:00
subscription_strategy Speed up send email notification task (#3713) 2024-01-18 13:54:18 +00:00
tests refactor SlackMessage.channel_id (CHAR field) to SlackMessage.channel (foreign key relationship) (#5292) 2024-11-26 11:03:38 +00:00
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
apps.py Update ical event/user email matching to be case-insensitive 2022-10-20 16:12:41 -03:00
constants.py Google OAuth2 flow + fetch Google Calendar OOO events (#4067) 2024-04-02 14:59:03 -04:00
exceptions.py Org soft-delete (#1073) 2023-01-05 12:42:55 +08:00
middlewares.py Handle Amazon SNS headers for moved (#3371) 2023-11-16 13:44:56 -07:00
signals.py add several new database columns + emit two new Django signals (#1522) 2023-04-14 09:15:57 +02:00
sync.py Fix irm enabled organization sync setting (#5174) 2024-10-14 13:34:33 +00:00
types.py Google OAuth2 flow + fetch Google Calendar OOO events (#4067) 2024-04-02 14:59:03 -04:00
user_representative.py apps.get_model -> import (#2619) 2023-07-25 09:43:23 +00:00