Issue Details (XML | Word | Printable)

Key: XWIKI-1569
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Artem Melentev
Reporter: Artem Melentev
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XWiki Core

Store migration system

Created: 08/Aug/07 20:50   Updated: 27/Nov/07 11:44
Component/s: Storage
Affects Version/s: 1.1 M3
Fix Version/s: 1.2 M1

Issue Links:
Dependency
 
Related
 

keywords: DBImprovement
Resolution Date: 16/Aug/07 00:53


 Description  « Hide
XWiki needs migration system for easy migrate from old database.
XWIKI-883, XWIKI-1459, XWIKI-1468 needs migration.

Implementation:
1. store special xwiki data version number in database (svn revision number)
2. migrations will be like patches from one data version to another.
3. migrations runs from XWiki.initXWiki, after all store systems initialized, but xwiki initialization is not finish. So migrations can use store system. (high-level)
4. migration can be turned off at xwiki.cfg (off by default for tests. parameter xwiki.store.migration)
5. some migrations can be forced or ignored at xwiki.cfg (parameters xwiki.store.migration.ignore=verions, xwiki.store.migration.force=classnames)

Questions:
1. How identify migrations?
Will it be class extends Migrator with name "R" + svn revision number + jiraIssue+"Migrator"?
2. How register migrations in migrationManager?
Register all classes in package "com.xpn.xwiki.store.migration.hibernate" via classloader?

Example use case:

/**
 * Migrator for something. Jira issue XWIKI-1234.
 * @version $Id: $
 */
public class R4326XWiki1234Migrator extends AbstractXWikiHibernateMigrator
{
    /** {@inheritDoc} */
    public XWikiDBVersion getVersion()
    {
        return new XWikiDBVersion(4326);
    }
    /** {@inheritDoc} */
    public void migrate(XWikiHibernateMigrationManager manager, XWikiContext context)
        throws XWikiException
    {
        manager.getStore(context).executeWrite(context, true, new HibernateCallback() {
            public Object doInHibernate(Session session) throws HibernateException
            {
                // here you can write migration
                return null;
            }
        });
    }
}


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Artem Melentev added a comment - 16/Aug/07 00:53
Added in r4345.
reopen, if you have remarks.