Run migrations! Some first auto-migrations

Stepped back some more ambitious migrations since they caused all sorts
of issues with bytes/str conversions.
This commit is contained in:
Griatch 2019-01-29 00:15:11 +01:00
parent bff8b9d6ad
commit 54e7376b31
5 changed files with 27 additions and 61 deletions

View file

@ -83,6 +83,10 @@ Web/Django standard initiative (@strikaco)
- Added more unit tests. - Added more unit tests.
### Server
- Convert ServerConf model to store its values as a Picklefield (same as Attributes) instead of using a custom solution.
### Utils ### Utils
- Swap argument order of `evennia.set_trace` to `set_trace(term_size=(140, 40), debugger='auto')` - Swap argument order of `evennia.set_trace` to `set_trace(term_size=(140, 40), debugger='auto')`
@ -95,6 +99,7 @@ Web/Django standard initiative (@strikaco)
str to bytes. str to bytes.
## Evennia 0.8 (2018) ## Evennia 0.8 (2018)
### Requirements ### Requirements

View file

@ -1,36 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 18:20
import pickle
from django.db import migrations, models
import evennia.utils.picklefield
from evennia.utils.utils import to_bytes, to_str
def migrate_serverconf(apps, schema_editor):
"""
Move server conf from a custom binary field into a PickleObjectField
"""
ServerConfig = apps.get_model("server", "ServerConfig")
for conf in ServerConfig.objects.all():
value = pickle.loads(to_bytes(conf.db_value))
conf.db_value2 = to_str(value)
conf.save(update_fields=["db_value2"])
class Migration(migrations.Migration):
dependencies = [
('server', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='serverconfig',
name='db_value2',
field=evennia.utils.picklefield.PickledObjectField(help_text='The data returned when the config value is accessed. Must be written as a Python literal if editing through the admin interface. Attribute values which are not Python literals cannot be edited through the admin interface.', null=True, verbose_name='value'),
),
# migrate data
migrations.RunPython(migrate_serverconf, migrations.RunPython.noop),
]

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 23:11
from __future__ import unicode_literals
from django.db import migrations
import evennia.utils.picklefield
class Migration(migrations.Migration):
dependencies = [
('server', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='serverconfig',
name='db_value',
field=evennia.utils.picklefield.PickledObjectField(help_text='The data returned when the config value is accessed. Must be written as a Python literal if editing through the admin interface. Attribute values which are not Python literals cannot be edited through the admin interface.', null=True, verbose_name='value'),
),
]

View file

@ -1,24 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 18:43
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('server', '0002_auto_20190128_1820'),
]
operations = [
migrations.RemoveField(
model_name='serverconfig',
name='db_value',
),
migrations.RenameField(
model_name='serverconfig',
old_name='db_value2',
new_name='db_value',
),
]

View file

@ -25,7 +25,7 @@
""" """
Pickle field implementation for Django. Pickle field implementation for Django.
Modified for Evennia by Griatch. Modified for Evennia by Griatch and the Evennia community.
""" """
from builtins import object from builtins import object