# What this PR does This PR adds [django-migration-linter](https://github.com/3YOURMIND/django-migration-linter) to keep database migrations backwards compatible - we can automatically run migrations and they are zero-downtime, e.g. old code can work with the migrated database - we can run and rollback migrations without worrying about data safety - OnCall is deployed to the multiple environments core team is not able to control See [django-migration-linter checklist](https://github.com/3YOURMIND/django-migration-linter/blob/main/docs/incompatibilities.md) for the common mistakes and best practices ## Which issue(s) this PR fixes ## Checklist - [ ] Tests updated - [ ] Documentation added - [ ] `CHANGELOG.md` updated --------- Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
30 lines
901 B
Python
30 lines
901 B
Python
# Generated by Django 3.2.15 on 2022-09-01 16:54
|
|
|
|
from django.db import migrations
|
|
|
|
from apps.alerts.models import AlertReceiveChannel
|
|
from apps.alerts.tasks import update_web_title_cache_for_alert_receive_channel
|
|
import django_migration_linter as linter
|
|
|
|
|
|
def populate_web_title_cache(apps, _):
|
|
pks = AlertReceiveChannel.objects_with_deleted.values_list("pk", flat=True)
|
|
for pk in pks:
|
|
update_web_title_cache_for_alert_receive_channel.delay(pk)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('alerts', '0006_alertgroup_alerts_aler_channel_ee84a7_idx'),
|
|
]
|
|
|
|
operations = [
|
|
linter.IgnoreMigration(),
|
|
migrations.RenameField(
|
|
model_name='alertgroup',
|
|
old_name='verbose_name',
|
|
new_name='web_title_cache',
|
|
),
|
|
migrations.RunPython(populate_web_title_cache, migrations.RunPython.noop),
|
|
]
|