# HG changeset patch # User Sylvain Thénault # Date 1282051439 -7200 # Node ID 56ec278b843e9f08b12c176f121eefb40398d3a8 # Parent 3e1718a2db5501120a867bc31dd50b10fc41ab86 [migration] we can now specify attributes to backport to rename_entity_type using its attrs argument diff -r 3e1718a2db55 -r 56ec278b843e server/migractions.py --- a/server/migractions.py Tue Aug 17 15:22:57 2010 +0200 +++ b/server/migractions.py Tue Aug 17 15:23:59 2010 +0200 @@ -845,7 +845,7 @@ if commit: self.commit() - def cmd_rename_entity_type(self, oldname, newname, commit=True): + def cmd_rename_entity_type(self, oldname, newname, attrs=None, commit=True): """rename an existing entity type in the persistent schema `oldname` is a string giving the name of the existing entity type @@ -854,11 +854,17 @@ schema = self.repo.schema if newname in schema: assert oldname in ETYPE_NAME_MAP, \ - '%s should be mappend to %s in ETYPE_NAME_MAP' % (oldname, newname) - attrs = ','.join([SQL_PREFIX + rschema.type - for rschema in schema[newname].subject_relations() - if (rschema.final or rschema.inlined) - and not rschema in PURE_VIRTUAL_RTYPES]) + '%s should be mapped to %s in ETYPE_NAME_MAP' % (oldname, + newname) + if attrs is None: + attrs = ','.join(SQL_PREFIX + rschema.type + for rschema in schema[newname].subject_relations() + if (rschema.final or rschema.inlined) + and rschema in schema[oldname].subjrels + and not rschema in PURE_VIRTUAL_RTYPES) + else: + attrs += ('eid', 'creation_date', 'modification_date', 'cwuri') + attrs = ','.join(SQL_PREFIX + attr for attr in attrs) self.sqlexec('INSERT INTO %s%s(%s) SELECT %s FROM %s%s' % ( SQL_PREFIX, newname, attrs, attrs, SQL_PREFIX, oldname), ask_confirm=False)