# HG changeset patch # User Sylvain Thénault # Date 1248441224 -7200 # Node ID 00f3b102b2c575db985417897cb830c08827a9e0 # Parent 24bad65dbebdfb20cffeb9f30fbe9bd74cd95525# Parent ae74b46ea96c1ff62c90c156f5166df1cd0d1468 merge diff -r ae74b46ea96c -r 00f3b102b2c5 common/migration.py --- a/common/migration.py Fri Jul 24 15:00:49 2009 +0200 +++ b/common/migration.py Fri Jul 24 15:13:44 2009 +0200 @@ -152,11 +152,15 @@ migrdir = self.config.cube_migration_scripts_dir(cube) scripts = filter_scripts(self.config, migrdir, fromversion, toversion) if scripts: + prevversion = None for version, script in scripts: + # take care to X.Y.Z_Any.py / X.Y.Z_common.py: we've to call + # cube_upgraded once all script of X.Y.Z have been executed + if prevversion is not None and version != prevversion: + self.cube_upgraded(cube, version) + prevversion = version self.process_script(script) - self.cube_upgraded(cube, version) - if version != toversion: - self.cube_upgraded(cube, toversion) + self.cube_upgraded(cube, toversion) else: self.cube_upgraded(cube, toversion) diff -r ae74b46ea96c -r 00f3b102b2c5 doc/book/en/development/migration/index.rst --- a/doc/book/en/development/migration/index.rst Fri Jul 24 15:00:49 2009 +0200 +++ b/doc/book/en/development/migration/index.rst Fri Jul 24 15:13:44 2009 +0200 @@ -67,8 +67,8 @@ * `interactive_mode`, boolean indicating that the script is executed in an interactive mode or not -* `versions_map`, dictionary of versions used by this instance (key are cubes - names, including 'cubicweb', values are version, eg 3-uple) +* `versions_map`, dictionary of migrated versions (key are cubes + names, including 'cubicweb', values are (from version, to version) * `confirm(question)`, function asking the user and returning true if the user answers yes, false otherwise (always returns true in diff -r ae74b46ea96c -r 00f3b102b2c5 misc/migration/3.4.0_common.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/migration/3.4.0_common.py Fri Jul 24 15:13:44 2009 +0200 @@ -0,0 +1,1 @@ +option_renamed('pyro-application-id', 'pyro-instance-id') diff -r ae74b46ea96c -r 00f3b102b2c5 misc/migration/bootstrapmigration_repository.py --- a/misc/migration/bootstrapmigration_repository.py Fri Jul 24 15:00:49 2009 +0200 +++ b/misc/migration/bootstrapmigration_repository.py Fri Jul 24 15:13:44 2009 +0200 @@ -11,6 +11,7 @@ applcubicwebversion, cubicwebversion = versions_map['cubicweb'] if applcubicwebversion < (3, 4, 0) and cubicwebversion >= (3, 4, 0): + from cubicweb import RepositoryError from cubicweb.server.hooks import uniquecstrcheck_before_modification session.set_shared_data('do-not-insert-cwuri', True) repo.hm.unregister_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') @@ -20,8 +21,11 @@ # use an internal session since some entity might forbid modifications to admin isession = repo.internal_session() for eid, in rql('Any X', ask_confirm=False): - isession.execute('SET X cwuri %(u)s WHERE X eid %(x)s', - {'x': eid, 'u': base_url + u'eid/%s' % eid}) + try: + isession.execute('SET X cwuri %(u)s WHERE X eid %(x)s', + {'x': eid, 'u': base_url + u'eid/%s' % eid}) + except RepositoryError: + print 'unable to set cwuri for', eid, session.describe(eid) isession.commit() repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_update_entity', '')