oncall-engine/engine/apps/schedules/migrations/0001_squashed_initial.py
Ildar Iskhakov 1b7ada4315
Add database migrations linter (#1020)
# 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>
2023-02-06 16:01:37 +08:00

96 lines
5.8 KiB
Python

# Generated by Django 3.2.5 on 2022-05-31 14:46
import apps.schedules.models.custom_on_call_shift
import apps.schedules.models.on_call_schedule
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import uuid
import django_migration_linter as linter
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
linter.IgnoreMigration(),
migrations.CreateModel(
name='CustomOnCallShift',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('public_primary_key', models.CharField(default=apps.schedules.models.custom_on_call_shift.generate_public_primary_key_for_custom_oncall_shift, max_length=20, unique=True, validators=[django.core.validators.MinLengthValidator(13)])),
('name', models.CharField(max_length=200)),
('time_zone', models.CharField(default=None, max_length=100, null=True)),
('source', models.IntegerField(choices=[(0, 'web'), (1, 'api'), (2, 'slack'), (3, 'terraform')], default=1)),
('rolling_users', models.JSONField(default=None, null=True)),
('start_rotation_from_user_index', models.PositiveIntegerField(default=None, null=True)),
('uuid', models.UUIDField(default=uuid.uuid4)),
('type', models.IntegerField(choices=[(0, 'Single event'), (1, 'Recurrent event'), (2, 'Rolling users')])),
('start', models.DateTimeField()),
('duration', models.DurationField()),
('frequency', models.IntegerField(choices=[(0, 'Daily'), (1, 'Weekly'), (2, 'Monthly')], default=None, null=True)),
('priority_level', models.IntegerField(default=0)),
('interval', models.IntegerField(default=None, null=True)),
('week_start', models.IntegerField(choices=[(0, 'Monday'), (1, 'Tuesday'), (2, 'Wednesday'), (3, 'Thursday'), (4, 'Friday'), (5, 'Saturday'), (6, 'Sunday')], default=6)),
('by_day', models.JSONField(default=None, null=True)),
('by_month', models.JSONField(default=None, null=True)),
('by_monthday', models.JSONField(default=None, null=True)),
],
),
migrations.CreateModel(
name='OnCallSchedule',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('public_primary_key', models.CharField(default=apps.schedules.models.on_call_schedule.generate_public_primary_key_for_oncall_schedule_channel, max_length=20, unique=True, validators=[django.core.validators.MinLengthValidator(13)])),
('cached_ical_file_primary', models.TextField(default=None, null=True)),
('prev_ical_file_primary', models.TextField(default=None, null=True)),
('cached_ical_file_overrides', models.TextField(default=None, null=True)),
('prev_ical_file_overrides', models.TextField(default=None, null=True)),
('name', models.CharField(max_length=200)),
('channel', models.CharField(default=None, max_length=100, null=True)),
('current_shifts', models.TextField(default='{}')),
('empty_oncall', models.BooleanField(default=True)),
('notify_oncall_shift_freq', models.IntegerField(choices=[(0, 'Never'), (1, 'Each shift')], default=1)),
('mention_oncall_start', models.BooleanField(default=True)),
('mention_oncall_next', models.BooleanField(default=False)),
('notify_empty_oncall', models.IntegerField(choices=[(0, 'Notify all people in the channel'), (1, 'Mention person from the previous slot'), (2, 'Inform about empty slot')], default=0)),
('has_gaps', models.BooleanField(default=False)),
('gaps_report_sent_at', models.DateField(default=None, null=True)),
('has_empty_shifts', models.BooleanField(default=False)),
('empty_shifts_report_sent_at', models.DateField(default=None, null=True)),
],
),
migrations.CreateModel(
name='OnCallScheduleCalendar',
fields=[
('oncallschedule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='schedules.oncallschedule')),
('ical_url_overrides', models.CharField(default=None, max_length=500, null=True)),
('ical_file_error_overrides', models.CharField(default=None, max_length=200, null=True)),
('time_zone', models.CharField(default='UTC', max_length=100)),
],
options={
'abstract': False,
'base_manager_name': 'objects',
},
bases=('schedules.oncallschedule',),
),
migrations.CreateModel(
name='OnCallScheduleICal',
fields=[
('oncallschedule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='schedules.oncallschedule')),
('ical_url_primary', models.CharField(default=None, max_length=500, null=True)),
('ical_file_error_primary', models.CharField(default=None, max_length=200, null=True)),
('ical_url_overrides', models.CharField(default=None, max_length=500, null=True)),
('ical_file_error_overrides', models.CharField(default=None, max_length=200, null=True)),
],
options={
'abstract': False,
'base_manager_name': 'objects',
},
bases=('schedules.oncallschedule',),
),
]