models: Add missing migrations from invite_as change.

I neglected to `git add` after doing `renumber-migrations` for
1f8f227444.
This commit is contained in:
Tim Abbott 2020-06-24 11:38:41 -07:00
parent ac9ecbe8de
commit 2a6ef2b9eb
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 2.2.13 on 2020-06-21 21:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('zerver', '0291_realm_retention_days_not_null'),
]
operations = [
migrations.AlterField(
model_name='multiuseinvite',
name='invited_as',
field=models.PositiveSmallIntegerField(default=400),
),
migrations.AlterField(
model_name='preregistrationuser',
name='invited_as',
field=models.PositiveSmallIntegerField(default=400),
),
]

View File

@ -0,0 +1,53 @@
# Generated by Django 2.2.13 on 2020-06-21 21:13
from django.db import migrations
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def update_invite_as_dict_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
PreregistrationUser = apps.get_model('zerver', 'PreregistrationUser')
MultiuseInvite = apps.get_model('zerver', 'MultiuseInvite')
OLD_INVITE_AS_DICT = dict(
MEMBER = 1,
REALM_ADMIN = 2,
GUEST_USER = 3,
REALM_OWNER = 4,
)
NEW_INVITE_AS_DICT = dict(
REALM_OWNER = 100,
REALM_ADMIN = 200,
MEMBER = 400,
GUEST_USER = 600,
)
PreregistrationUser.objects.filter(invited_as=OLD_INVITE_AS_DICT['REALM_OWNER']) \
.update(invited_as=NEW_INVITE_AS_DICT['REALM_OWNER'])
PreregistrationUser.objects.filter(invited_as=OLD_INVITE_AS_DICT['REALM_ADMIN']) \
.update(invited_as=NEW_INVITE_AS_DICT['REALM_ADMIN'])
PreregistrationUser.objects.filter(invited_as=OLD_INVITE_AS_DICT['MEMBER']) \
.update(invited_as=NEW_INVITE_AS_DICT['MEMBER'])
PreregistrationUser.objects.filter(invited_as=OLD_INVITE_AS_DICT['GUEST_USER']) \
.update(invited_as=NEW_INVITE_AS_DICT['GUEST_USER'])
MultiuseInvite.objects.filter(invited_as=OLD_INVITE_AS_DICT['REALM_OWNER']) \
.update(invited_as=NEW_INVITE_AS_DICT['REALM_OWNER'])
MultiuseInvite.objects.filter(invited_as=OLD_INVITE_AS_DICT['REALM_ADMIN']) \
.update(invited_as=NEW_INVITE_AS_DICT['REALM_ADMIN'])
MultiuseInvite.objects.filter(invited_as=OLD_INVITE_AS_DICT['MEMBER']) \
.update(invited_as=NEW_INVITE_AS_DICT['MEMBER'])
MultiuseInvite.objects.filter(invited_as=OLD_INVITE_AS_DICT['GUEST_USER']) \
.update(invited_as=NEW_INVITE_AS_DICT['GUEST_USER'])
class Migration(migrations.Migration):
dependencies = [
('zerver', '0292_update_default_value_of_invited_as'),
]
operations = [
migrations.RunPython(update_invite_as_dict_values,
reverse_code=migrations.RunPython.noop,
elidable=True),
]