--- a/server/migractions.py Thu May 19 18:48:26 2011 +0200
+++ b/server/migractions.py Fri May 20 17:29:50 2011 +0200
@@ -1423,7 +1423,7 @@
return self.cmd_create_entity(etype, *args, **kwargs).eid
@contextmanager
- def cmd_dropped_constraints(self, etype, attrname, cstrtype,
+ def cmd_dropped_constraints(self, etype, attrname, cstrtype=None,
droprequired=False):
"""context manager to drop constraints temporarily on fs_schema
@@ -1443,8 +1443,9 @@
rdef = self.fs_schema.eschema(etype).rdef(attrname)
original_constraints = rdef.constraints
# remove constraints
- rdef.constraints = [cstr for cstr in original_constraints
- if not (cstrtype and isinstance(cstr, cstrtype))]
+ if cstrtype:
+ rdef.constraints = [cstr for cstr in original_constraints
+ if not (cstrtype and isinstance(cstr, cstrtype))]
if droprequired:
original_cardinality = rdef.cardinality
rdef.cardinality = '?' + rdef.cardinality[1]
@@ -1514,13 +1515,13 @@
rschema = self.repo.schema.rschema(attr)
oldtype = rschema.objects(etype)[0]
rdefeid = rschema.rproperty(etype, oldtype, 'eid')
- sql = ("UPDATE CWAttribute "
- "SET to_entity=(SELECT eid FROM CWEType WHERE name='%s')"
- "WHERE eid=%s") % (newtype, rdefeid)
+ sql = ("UPDATE cw_CWAttribute "
+ "SET cw_to_entity=(SELECT cw_eid FROM cw_CWEType WHERE cw_name='%s')"
+ "WHERE cw_eid=%s") % (newtype, rdefeid)
self.sqlexec(sql, ask_confirm=False)
dbhelper = self.repo.system_source.dbhelper
sqltype = dbhelper.TYPE_MAPPING[newtype]
- sql = 'ALTER TABLE %s ALTER COLUMN %s TYPE %s' % (etype, attr, sqltype)
+ sql = 'ALTER TABLE cw_%s ALTER COLUMN cw_%s TYPE %s' % (etype, attr, sqltype)
self.sqlexec(sql, ask_confirm=False)
if commit:
self.commit()