I'm not understanding how to execute an inplace migration via upgrade steps. I want to rename a field and migrate it's contents from the old name to the new name. Running the steps through portal_setup does execute, however, the data stored in the field does not migrate as expected. Also, the tests are failing because the old object is getting created with the new schema. Any help would be appreciated. I can include the tests if that is helpful.
Tutorial Followed: http://plone.org/documentation/kb/migrate-custom-types-with-products.contentmigration Working on plone 4.0.5 and migrating from mypackage.plone 0.5 to 0.5.1 mypackage.plone.upgrade/configure.zcml: <configure xmlns="http://namespaces.zope.org/zope" xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="mypackage"> <include package=".to051" /> </configure> mypackage.plone.upgrade/to051/__init__.py: from Products.CMFCore.utils import getToolByName from plone.app.upgrade.utils import logger from plone.app.upgrade.utils import loadMigrationProfile def convertPageObjects(context): """Remove old Page object schema for new We disable link integrity checks here, as the migration only removes objects to recreate them fresh, so in the end nothing is permanently removed. """ logger.info('Started migration of link objects.') from mypackage.upgrade.to051.migrations import migratePageObjects sprop = getToolByName(context, 'portal_properties').site_properties if sprop.hasProperty('enable_link_integrity_checks'): ori_enable_link_integrity_checks = sprop.getProperty('enable_link_integrity_checks') if ori_enable_link_integrity_checks: logger.info('Temporarily disabled link integrity checking') sprop.enable_link_integrity_checks = False else: ori_enable_link_integrity_checks = None output = migratePageObjects(context) count = len(output.split('\n')) - 1 logger.info('Migrated %s files to new link.' % count) mypackage.plone.upgrade/to051/configure.zcml: <configure xmlns="http://namespaces.zope.org/zope" xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="mypackage"> <genericsetup:upgradeSteps source="0.5" destination="0.5.1" profile="mypackage.plone:default"> <genericsetup:upgradeStep title="Upgrade Page Object Schema" handler="mypackage.plone.upgrade.to051.convertPageObjects" /> </genericsetup:upgradeSteps> </configure> mypackage.plone.upgrade/to051/migrations.py: try: from Products.contentmigration.archetypes import InplaceATItemMigrator from Products.contentmigration.walker import CustomQueryWalker haveContentMigrations = True BaseMigrator = InplaceATItemMigrator except ImportError: BaseMigrator = object haveContentMigrations = False from transaction import savepoint from Products.CMFCore.utils import getToolByName from Products.Archetypes.interfaces import ISchema def getMigrationWalker(context, migrator): """ set up migration walker using the given item migrator """ portal = getToolByName(context, 'portal_url').getPortalObject() return CustomQueryWalker(portal, migrator, use_savepoint=True) def migrate(context, portal_type=None, meta_type=None, walker=None): """ migrate instances using the given walker """ walker = walker(context) savepoint(optimistic=True) walker.go() return walker.getOutput() # migration of file content to new content type class PageObjectMigrator(BaseMigrator): src_portal_type = 'Page' src_meta_type = 'Page' dst_portal_type = 'Page' dst_meta_type = 'Page' ## Basically we delete content from fields if exists fields_map = { 'newsSource' : 'source', } def last_migrate_reindex(self): self.new.reindexObject(idxs=['object_provides', 'portal_type', 'Type', 'UID']) def getPageObjectsMigrationWalker(self): return getMigrationWalker(self, migrator=PageObjectMigrator) def migratePageObjects(self): return migrate(self, walker=getPageObjectsMigrationWalker) _______________________________________________ Product-Developers mailing list [email protected] https://lists.plone.org/mailman/listinfo/plone-product-developers
