262 """checkpoint action""" |
262 """checkpoint action""" |
263 if self.confirm('commit now ?', shell=False): |
263 if self.confirm('commit now ?', shell=False): |
264 self.commit() |
264 self.commit() |
265 |
265 |
266 def cmd_add_cube(self, cube, update_database=True): |
266 def cmd_add_cube(self, cube, update_database=True): |
|
267 self.cmd_add_cubes( (cube,), update_database) |
|
268 |
|
269 def cmd_add_cubes(self, cubes, update_database=True): |
267 """update_database is telling if the database schema should be updated |
270 """update_database is telling if the database schema should be updated |
268 or if only the relevant eproperty should be inserted (for the case where |
271 or if only the relevant eproperty should be inserted (for the case where |
269 a cube has been extracted from an existing application, so the |
272 a cube has been extracted from an existing application, so the |
270 cube schema is already in there) |
273 cube schema is already in there) |
271 """ |
274 """ |
272 newcubes = super(ServerMigrationHelper, self).cmd_add_cube( |
275 newcubes = super(ServerMigrationHelper, self).cmd_add_cubes(cubes) |
273 cube) |
|
274 if not newcubes: |
276 if not newcubes: |
275 return |
277 return |
276 for pack in newcubes: |
278 for pack in newcubes: |
277 self.cmd_set_property('system.version.'+pack, |
279 self.cmd_set_property('system.version.'+pack, |
278 self.config.cube_version(pack)) |
280 self.config.cube_version(pack)) |
279 if not update_database: |
281 if not update_database: |
280 self.commit() |
282 self.commit() |
281 return |
283 return |
282 self.new_schema = self.config.load_schema() |
284 with_new_cubes = self.config.load_schema() |
283 new = set() |
285 new = set() |
284 # execute pre-create files |
286 # execute pre-create files |
285 for pack in reversed(newcubes): |
287 for pack in reversed(newcubes): |
286 self.exec_event_script('precreate', self.config.cube_dir(pack)) |
288 self.exec_event_script('precreate', self.config.cube_dir(pack)) |
287 # add new entity and relation types |
289 # add new entity and relation types |
288 for rschema in self.new_schema.relations(): |
290 for rschema in with_new_cubes.relations(): |
289 if not rschema in self.repo.schema: |
291 if not rschema in self.repo.schema: |
290 self.cmd_add_relation_type(rschema.type) |
292 self.cmd_add_relation_type(rschema.type) |
291 new.add(rschema.type) |
293 new.add(rschema.type) |
292 for eschema in self.new_schema.entities(): |
294 for eschema in with_new_cubes.entities(): |
293 if not eschema in self.repo.schema: |
295 if not eschema in self.repo.schema: |
294 self.cmd_add_entity_type(eschema.type) |
296 self.cmd_add_entity_type(eschema.type) |
295 new.add(eschema.type) |
297 new.add(eschema.type) |
296 # check if attributes has been added to existing entities |
298 # check if attributes has been added to existing entities |
297 for rschema in self.new_schema.relations(): |
299 for rschema in with_new_cubes.relations(): |
298 existingschema = self.repo.schema.rschema(rschema.type) |
300 existingschema = self.repo.schema.rschema(rschema.type) |
299 for (fromtype, totype) in rschema.iter_rdefs(): |
301 for (fromtype, totype) in rschema.iter_rdefs(): |
300 if existingschema.has_rdef(fromtype, totype): |
302 if existingschema.has_rdef(fromtype, totype): |
301 continue |
303 continue |
302 # check we should actually add the relation definition |
304 # check we should actually add the relation definition |