server/migractions.py
changeset 2617 89c62b855f2e
parent 2616 4501ee760eec
child 2680 66472d85d548
equal deleted inserted replaced
2616:4501ee760eec 2617:89c62b855f2e
    28 
    28 
    29 from yams.constraints import SizeConstraint
    29 from yams.constraints import SizeConstraint
    30 from yams.schema2sql import eschema2sql, rschema2sql
    30 from yams.schema2sql import eschema2sql, rschema2sql
    31 
    31 
    32 from cubicweb import AuthenticationError, ETYPE_NAME_MAP
    32 from cubicweb import AuthenticationError, ETYPE_NAME_MAP
    33 from cubicweb.schema import VIRTUAL_RTYPES, CubicWebRelationSchema
    33 from cubicweb.schema import META_RTYPES, VIRTUAL_RTYPES, CubicWebRelationSchema
    34 from cubicweb.dbapi import get_repository, repo_connect
    34 from cubicweb.dbapi import get_repository, repo_connect
    35 from cubicweb.common.migration import MigrationHelper, yes
    35 from cubicweb.common.migration import MigrationHelper, yes
    36 
    36 
    37 try:
    37 try:
    38     from cubicweb.server import SOURCE_TYPES, schemaserial as ss
    38     from cubicweb.server import SOURCE_TYPES, schemaserial as ss
   585         self.rqlexecall(ss.erperms2rql(eschema, self.group_mapping()),
   585         self.rqlexecall(ss.erperms2rql(eschema, self.group_mapping()),
   586                         ask_confirm=confirm)
   586                         ask_confirm=confirm)
   587         # register entity's attributes
   587         # register entity's attributes
   588         for rschema, attrschema in eschema.attribute_definitions():
   588         for rschema, attrschema in eschema.attribute_definitions():
   589             # ignore those meta relations, they will be automatically added
   589             # ignore those meta relations, they will be automatically added
   590             if rschema.type in ('eid', 'creation_date', 'modification_date'):
   590             if rschema.type in META_RTYPES:
   591                 continue
   591                 continue
   592             if not rschema.type in applschema:
   592             if not rschema.type in applschema:
   593                 # need to add the relation type and to commit to get it
   593                 # need to add the relation type and to commit to get it
   594                 # actually in the schema
   594                 # actually in the schema
   595                 self.cmd_add_relation_type(rschema.type, False, commit=True)
   595                 self.cmd_add_relation_type(rschema.type, False, commit=True)
   601             self.commit()
   601             self.commit()
   602             added = []
   602             added = []
   603             for rschema in eschema.subject_relations():
   603             for rschema in eschema.subject_relations():
   604                 # attribute relation have already been processed and
   604                 # attribute relation have already been processed and
   605                 # 'owned_by'/'created_by' will be automatically added
   605                 # 'owned_by'/'created_by' will be automatically added
   606                 if rschema.final or rschema.type in ('owned_by', 'created_by', 'is', 'is_instance_of'):
   606                 if rschema.final or rschema.type in META_RTYPES:
   607                     continue
   607                     continue
   608                 rtypeadded = rschema.type in applschema
   608                 rtypeadded = rschema.type in applschema
   609                 for targetschema in rschema.objects(etype):
   609                 for targetschema in rschema.objects(etype):
   610                     # ignore relations where the targeted type is not in the
   610                     # ignore relations where the targeted type is not in the
   611                     # current instance schema
   611                     # current instance schema