mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 04:27:16 +02:00
Fixed an issue with case sensitivity in table names for the migrations. Fixed issue with transactions when converting nicks and aliases.
This commit is contained in:
parent
90faaf9d01
commit
da097a88d9
2 changed files with 18 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ class Migration(SchemaMigration):
|
|||
|
||||
def forwards(self, orm):
|
||||
|
||||
db.rename_table('players_PlayerDBtmp', 'players_PlayerDB')
|
||||
db.rename_table('players_playerdbtmp', 'players_playerdb')
|
||||
|
||||
def backwards(self, orm):
|
||||
raise RuntimeError("Cannot revert this migration.")
|
||||
|
|
|
|||
|
|
@ -13,32 +13,49 @@ class Migration(DataMigration):
|
|||
# Note: Don't use "from appname.models import ModelName".
|
||||
# Use orm.ModelName to refer to models in this application,
|
||||
# and orm['appname.ModelName'] for models in other applications.
|
||||
|
||||
# Each alias and nick is its own case. By default, this function starts
|
||||
# in a transaction, so we'll close that and make our own transactions.
|
||||
db.commit_transaction()
|
||||
|
||||
for alias in orm['objects.Alias'].objects.all():
|
||||
# convert all Aliases to tags
|
||||
try:
|
||||
db.start_transaction()
|
||||
tag = orm.Tag(db_key=alias.db_key, db_category="object_alias", db_data=None)
|
||||
tag.save()
|
||||
obj = alias.db_obj
|
||||
obj.db_tags.add(tag)
|
||||
db.commit_transaction()
|
||||
except IntegrityError:
|
||||
db.commit_transaction()
|
||||
print "Tag already exists: %s for %s" % (alias.db_key, alias.db_obj.db_key)
|
||||
# convert all nicks to LiteAttrs
|
||||
for nick in orm['objects.ObjectNick'].objects.all():
|
||||
try:
|
||||
db.start_transaction()
|
||||
lattr = orm.LiteAttribute(db_key=nick.db_nick, db_category="object_nick_%s" % nick.db_type, db_data=nick.db_real)
|
||||
lattr.save()
|
||||
obj = nick.db_obj
|
||||
obj.db_liteattributes.add(lattr)
|
||||
db.commit_transaction()
|
||||
except IntegrityError:
|
||||
db.commit_transaction()
|
||||
print "Nick already exists: %s for %s" % (nick.db_nick, nick.db_obj.db_key)
|
||||
for nick in orm['players.PlayerNick'].objects.all():
|
||||
try:
|
||||
db.start_transaction()
|
||||
lattr = orm.LiteAttribute(db_key=nick.db_nick, db_category="player_nick_%s" % nick.db_type, db_data=nick.db_real)
|
||||
lattr.save()
|
||||
obj = nick.db_obj
|
||||
obj.db_liteattributes.add(lattr)
|
||||
db.commit_transaction()
|
||||
except IntegrityError:
|
||||
db.commit_transaction()
|
||||
print "Nick already exists: %s for %s" % (nick.db_nick, nick.db_obj.db_key)
|
||||
# South expects the migration to be transaction managed. So start up a
|
||||
# new transaction for it to close immediately when it exits this function.
|
||||
db.commit_transaction()
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue