Fixed remaining issues with migrating the attribute changes.
This commit is contained in:
parent
230d73cfa0
commit
82c2e19ed5
2 changed files with 20 additions and 16 deletions
|
|
@ -270,7 +270,9 @@ class PackedSet(set):
|
||||||
|
|
||||||
|
|
||||||
class Migration(DataMigration):
|
class Migration(DataMigration):
|
||||||
|
depends_on = (
|
||||||
|
("objects", "0018_add_picklefield"),
|
||||||
|
)
|
||||||
def forwards(self, orm):
|
def forwards(self, orm):
|
||||||
"Write your forwards methods here."
|
"Write your forwards methods here."
|
||||||
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
|
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
|
||||||
|
|
@ -298,8 +300,7 @@ class Migration(DataMigration):
|
||||||
"""
|
"""
|
||||||
Convert db-stored dbref back to object
|
Convert db-stored dbref back to object
|
||||||
"""
|
"""
|
||||||
mclass = orm[data.db_model].model_class()
|
mclass = CTYPEGET(model=data.db_model).model_class()
|
||||||
#mclass = CTYPEGET(model=data.db_model).model_class()
|
|
||||||
try:
|
try:
|
||||||
return mclass.objects.get(id=data.id)
|
return mclass.objects.get(id=data.id)
|
||||||
|
|
||||||
|
|
@ -343,18 +344,18 @@ class Migration(DataMigration):
|
||||||
# all types of iterables
|
# all types of iterables
|
||||||
return iter_id2db(data)
|
return iter_id2db(data)
|
||||||
|
|
||||||
if not db.dry_run:
|
if not db.dry_run:
|
||||||
for attr in orm['players.PlayerAttribute'].objects.all():
|
for attr in orm['players.PlayerAttribute'].objects.all():
|
||||||
# repack attr into new format and reimport
|
# repack attr into new format and reimport
|
||||||
datatuple = loads(to_str(attr.db_value))
|
datatuple = loads(to_str(attr.db_value))
|
||||||
python_data = from_attr(datatuple)
|
python_data = from_attr(datatuple)
|
||||||
new_data = to_pickle(python_data)
|
new_data = to_pickle(python_data)
|
||||||
attr.db_value2 = new_data # new pickleObjectField
|
attr.db_value2 = new_data # new pickleObjectField
|
||||||
attr.save()
|
attr.save()
|
||||||
|
|
||||||
def backwards(self, orm):
|
def backwards(self, orm):
|
||||||
"Write your backwards methods here."
|
"Write your backwards methods here."
|
||||||
raise RuntimeError("This migration cannot be reversed.")
|
raise RuntimeError("This migration cannot be reversed.")
|
||||||
|
|
||||||
models = {
|
models = {
|
||||||
'auth.group': {
|
'auth.group': {
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,10 @@ def to_attr(data):
|
||||||
|
|
||||||
class Migration(DataMigration):
|
class Migration(DataMigration):
|
||||||
|
|
||||||
|
depends_on = (
|
||||||
|
("objects", "0018_add_picklefield"),
|
||||||
|
)
|
||||||
|
|
||||||
def forwards(self, orm):
|
def forwards(self, orm):
|
||||||
"Write your forwards methods here."
|
"Write your forwards methods here."
|
||||||
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
|
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
|
||||||
|
|
@ -361,8 +365,7 @@ class Migration(DataMigration):
|
||||||
"""
|
"""
|
||||||
Convert db-stored dbref back to object
|
Convert db-stored dbref back to object
|
||||||
"""
|
"""
|
||||||
mclass = orm[data.db_model].model_class()
|
mclass = CTYPEGET(model=data.db_model).model_class()
|
||||||
#mclass = CTYPEGET(model=data.db_model).model_class()
|
|
||||||
try:
|
try:
|
||||||
return mclass.objects.get(id=data.id)
|
return mclass.objects.get(id=data.id)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue