Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-1569

Store migration system

    XMLWordPrintable

Details

    • New Feature
    • Resolution: Fixed
    • Major
    • 1.2 M1
    • 1.1 M3
    • Storage
    • None
    • DBImprovement

    Description

      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;
                  }
              });
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              amelentev Artem Melentev
              amelentev Artem Melentev
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: