Re: [xwiki-devs] [xwiki-notifications] r6377 - xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate
Hi Sergiu, Shouldn't this have been a new migrator instead? Artem had a comment about leaving the old XWD_ARCHIVE column in the document table. Lots of users have already executed this migrator so they won't execute this. So if it's important to have everyone in the same state, I think a new migrator would be maybe better. But then, maybe it's not important? Thanks -Vincent On Dec 14, 2007, at 2:14 PM, sdumitriu (SVN) wrote:
Author: sdumitriu Date: 2007-12-14 14:14:08 +0100 (Fri, 14 Dec 2007) New Revision: 6377
Modified: xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/ store/migration/hibernate/R4359XWIKI1459Migrator.java Log: XWIKI-1954: When migrating the document archive format from 1.1 to 1.2, delete the contents of the old XWD_ARCHIVE field Fixed.
Modified: xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/ xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java =================================================================== --- xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/ store/migration/hibernate/R4359XWIKI1459Migrator.java 2007-12-14 13:08:02 UTC (rev 6376) +++ xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/ store/migration/hibernate/R4359XWIKI1459Migrator.java 2007-12-14 13:14:08 UTC (rev 6377) @@ -19,6 +19,7 @@ */ package com.xpn.xwiki.store.migration.hibernate;
+import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -88,7 +89,7 @@ Statement stmt = session.connection().createStatement(); ResultSet rs; try { - rs = stmt.executeQuery("select XWD_ID, XWD_ARCHIVE, XWD_FULLNAME from xwikidoc"); + rs = stmt.executeQuery("select XWD_ID, XWD_ARCHIVE, XWD_FULLNAME from xwikidoc where XWD_ARCHIVE is not null order by XWD_VERSION"); } catch (SQLException e) { // most likely there is no XWD_ARCHIVE column, so migration is not needed // is there easier way to find what column is not exist? @@ -97,6 +98,7 @@ Transaction originalTransaction = ((XWikiHibernateVersioningStore )context.getWiki().getVersioningStore()).getTransaction(context);
((XWikiHibernateVersioningStore )context.getWiki().getVersioningStore()).setSession(null, context);
((XWikiHibernateVersioningStore )context.getWiki().getVersioningStore()).setTransaction(null, context); + PreparedStatement deleleteStatement = session.connection().prepareStatement("update xwikidoc set XWD_ARCHIVE=null where XWD_ID=?");
while (rs.next()) { if (logger.isInfoEnabled()) { @@ -104,13 +106,13 @@ } long docId = Long.parseLong(rs.getString(1)); String sArchive = rs.getString(2); - if (sArchive==null) { - continue; - } XWikiDocumentArchive docArchive = new XWikiDocumentArchive(docId); docArchive.setArchive(sArchive);
context .getWiki().getVersioningStore().saveXWikiDocArchive(docArchive, true, context); + deleleteStatement.setLong(1, docId); + deleleteStatement.executeUpdate(); } + deleleteStatement.close(); stmt.close();
((XWikiHibernateVersioningStore )context.getWiki().getVersioningStore()).setSession(session, context);
((XWikiHibernateVersioningStore )context .getWiki().getVersioningStore()).setTransaction(originalTransaction, context);
_______________________________________________ notifications mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/notifications
Vincent Massol wrote:
Hi Sergiu,
Shouldn't this have been a new migrator instead? Artem had a comment about leaving the old XWD_ARCHIVE column in the document table. Lots of users have already executed this migrator so they won't execute this. So if it's important to have everyone in the same state, I think a new migrator would be maybe better. But then, maybe it's not important?
Thanks -Vincent
Indeed, for those that already ran the old migrator, it will not be executed again, so a new one would be needed. But I introduced this code in the existing migrator because the whole point was not to remove unused data from the deprecated column in order to reduce the space, but to prevent already processed archives from being processed in case the migrator blocks and must be restarted. So, the old archive must be deleted during the migration process to achieve this. Anyway, I'll write a new migrator after I finish the Rights UI bug. Sergiu
participants (2)
-
Sergiu Dumitriu -
Vincent Massol