From 54e7376b315f762ce1af5bee69db76188e90146b Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 29 Jan 2019 00:15:11 +0100 Subject: [PATCH] Run migrations! Some first auto-migrations Stepped back some more ambitious migrations since they caused all sorts of issues with bytes/str conversions. --- CHANGELOG.md | 5 +++ .../migrations/0002_auto_20190128_1820.py | 36 ------------------- .../migrations/0002_auto_20190128_2311.py | 21 +++++++++++ .../0003_remove_serverconfig_db_value.py | 24 ------------- evennia/utils/picklefield.py | 2 +- 5 files changed, 27 insertions(+), 61 deletions(-) delete mode 100644 evennia/server/migrations/0002_auto_20190128_1820.py create mode 100644 evennia/server/migrations/0002_auto_20190128_2311.py delete mode 100644 evennia/server/migrations/0003_remove_serverconfig_db_value.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aa6764e1c..2b77081ced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,10 @@ Web/Django standard initiative (@strikaco) - 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 - 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. + ## Evennia 0.8 (2018) ### Requirements diff --git a/evennia/server/migrations/0002_auto_20190128_1820.py b/evennia/server/migrations/0002_auto_20190128_1820.py deleted file mode 100644 index 597eb6b690..0000000000 --- a/evennia/server/migrations/0002_auto_20190128_1820.py +++ /dev/null @@ -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), - - - ] diff --git a/evennia/server/migrations/0002_auto_20190128_2311.py b/evennia/server/migrations/0002_auto_20190128_2311.py new file mode 100644 index 0000000000..297caed35b --- /dev/null +++ b/evennia/server/migrations/0002_auto_20190128_2311.py @@ -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'), + ), + ] diff --git a/evennia/server/migrations/0003_remove_serverconfig_db_value.py b/evennia/server/migrations/0003_remove_serverconfig_db_value.py deleted file mode 100644 index ca24c7ab6e..0000000000 --- a/evennia/server/migrations/0003_remove_serverconfig_db_value.py +++ /dev/null @@ -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', - ), - ] diff --git a/evennia/utils/picklefield.py b/evennia/utils/picklefield.py index 06ea5de0a4..d0ef53d01b 100644 --- a/evennia/utils/picklefield.py +++ b/evennia/utils/picklefield.py @@ -25,7 +25,7 @@ """ Pickle field implementation for Django. -Modified for Evennia by Griatch. +Modified for Evennia by Griatch and the Evennia community. """ from builtins import object