Run migrations! First version of the data migration for tags/attributes.
This commit is contained in:
parent
b6c2aaedc5
commit
807ca6c52c
2 changed files with 46 additions and 28 deletions
|
|
@ -1,28 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Generated by Django 1.9.11 on 2017-01-21 22:30
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
def update_tags_with_dbmodel(apps, schema_editor):
|
|
||||||
Tag = apps.get_model('typeclasses', 'Tag')
|
|
||||||
Attribute = apps.get_model('typeclasses', 'Attribute')
|
|
||||||
ObjectDB = apps.get_model('objects', 'ObjectDB')
|
|
||||||
PlayerDB = apps.get_model('players', 'PlayerDB')
|
|
||||||
ScriptDB = apps.get_model('scripts', 'ScriptDB')
|
|
||||||
HelpEntry = apps.get_model('help', 'HelpEntry')
|
|
||||||
Msg = apps.get_model('comms', 'Msg')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('typeclasses', '0005_auto_20160625_1812'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(update_tags_with_dbmodel)
|
|
||||||
]
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.11 on 2017-01-21 22:30
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def update_tags_with_dbmodel(apps, schema_editor):
|
||||||
|
|
||||||
|
ObjectDB = apps.get_model('objects', 'ObjectDB')
|
||||||
|
for obj in ObjectDB.objects.all():
|
||||||
|
obj.db_attributes.all().update(db_model="objectdb")
|
||||||
|
obj.db_tags.all().update(db_model="objectdb")
|
||||||
|
|
||||||
|
PlayerDB = apps.get_model('players', 'PlayerDB')
|
||||||
|
for obj in PlayerDB.objects.all():
|
||||||
|
obj.db_attributes.all().update(db_model="playerdb")
|
||||||
|
obj.db_tags.all().update(db_model="playerdb")
|
||||||
|
|
||||||
|
ScriptDB = apps.get_model('scripts', 'ScriptDB')
|
||||||
|
for obj in ScriptDB.objects.all():
|
||||||
|
obj.db_attributes.all().update(db_model="scriptdb")
|
||||||
|
obj.db_tags.all().update(db_model="scriptdb")
|
||||||
|
|
||||||
|
ChannelDB = apps.get_model('comms', 'ChannelDB')
|
||||||
|
for obj in ChannelDB.objects.all():
|
||||||
|
obj.db_attributes.all().update(db_model="channeldb")
|
||||||
|
obj.db_tags.all().update(db_model="channeldb")
|
||||||
|
|
||||||
|
HelpEntry = apps.get_model('help', 'HelpEntry')
|
||||||
|
for obj in HelpEntry.objects.all():
|
||||||
|
obj.db_tags.all().update(db_model="helpentry")
|
||||||
|
|
||||||
|
Msg = apps.get_model('comms', 'Msg')
|
||||||
|
for obj in Msg.objects.all():
|
||||||
|
obj.db_tags.all().update(db_model="msg")
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('typeclasses', '0005_auto_20160625_1812'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(update_tags_with_dbmodel)
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue