Commit 748e7eeb authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Migration script to move catalog to new ERP5Catalog object.

The script also changes the default_sql_catalog_id for the current portal_catalog
parent dc77678e
......@@ -1677,6 +1677,44 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
for obj in tool.objectValues():
obj.migrateToPortalTypeClass()
def migrateSQLCatalogToERP5Catalog(self):
"""
Migrate SQLCatalog objects to ERP5Catalog objects which is a Folder object
holding indexes of objects inside ERP5 Catalog Tool.
Create new ERP5Catalog object and copy the Catalog data from the Default
SQLCatalog object to this new object.
This function should be run at the end of ERP5 Site installation so as to
maintain consistency for the objects.
We will also shoft he default_sql_catalog_id to the new catalog object.
"""
# We'll be migrating Persistent Objects
from Products.ERP5Type.dynamic.persistent_migration import PickleUpdater
from Products.ERP5Catalog.ERP5Catalog import ERP5Catalog
PickleUpdater(self)
# Getting ERP5 Catalog Tool
tool = self.portal_catalog
sql_catalog = tool.getSQLCatalog()
new_id = 'erp5_mysql_innodb_new'
if not isinstance(sql_catalog, ERP5Catalog) and new_id \
not in self.portal_catalog.keys():
# Create new ERP5 Catalog
self.portal_catalog.manage_addProduct['ERP5Catalog'].manage_addERP5Catalog(
id = new_id,
title = '')
new_erp5_catalog = self._getOb('erp5_mysql_innodb_new')
# Copy data from erp5_mysql_innodb, which was the older SQL Catalog
catalog_data = self.portal_catalog.manage_copyObjects(ids=\
('erp5_mysql_innodb',))
# Paste catalog data from erp5_mysql_innodb which is a SQLCatalog.Catalog
# object to erp5_mysql_innodb_new, which is ERP5Catalog object
self.portal_catalog['erp5_mysql_innodb_new'].manage_pasteObjects(catalog_data)
# Use the new ERP5Catalog object as the default sql catalog
self.portal_catalog.default_sql_catalog_id = new_id
Globals.InitializeClass(ERP5Site)
def getBootstrapDirectory():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment