mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 14:07:16 +02:00
Add migration - run evennia migrate! This adds data migrations for new nick format.
This commit is contained in:
parent
316f03308e
commit
7f82049e33
1 changed files with 29 additions and 0 deletions
29
evennia/typeclasses/migrations/0005_auto_20160625_1812.py
Normal file
29
evennia/typeclasses/migrations/0005_auto_20160625_1812.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.7 on 2016-06-25 18:12
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
# Migration of old nick format to new
|
||||
|
||||
def update_nicks(apps, schema_editor):
|
||||
Attribute = apps.get_model("typeclasses", "Attribute")
|
||||
for nick in Attribute.objects.filter(db_attrtype="nick"):
|
||||
try:
|
||||
_, _, _, _ = nick.db_value
|
||||
except (TypeError, ValueError):
|
||||
# old setup, we store it in the new format - old uses its own key
|
||||
# as regex to keep the old matching (and has no $-type args)
|
||||
nick.db_value = (nick.db_key, nick.db_strvalue, nick.db_key, nick.db_strvalue)
|
||||
nick.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('typeclasses', '0004_auto_20151101_1759'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(update_nicks)
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue