001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.upgrade.v6_1_0;
016    
017    import com.liferay.portal.kernel.upgrade.UpgradeProcess;
018    import com.liferay.portal.upgrade.v6_1_0.util.JournalArticleTable;
019    import com.liferay.portal.upgrade.v6_1_0.util.JournalStructureTable;
020    import com.liferay.portal.upgrade.v6_1_0.util.JournalTemplateTable;
021    
022    import java.sql.SQLException;
023    
024    /**
025     * @author Juan Fernández
026     * @author Sergio González
027     */
028    public class UpgradeJournal extends UpgradeProcess {
029    
030            @Override
031            protected void doUpgrade() throws Exception {
032                    try {
033                            runSQL("alter_column_type JournalArticle title STRING null");
034    
035                            runSQL("alter_column_type JournalStructure name STRING null");
036                            runSQL(
037                                    "alter_column_type JournalStructure description STRING null");
038    
039                            runSQL("alter_column_type JournalTemplate name STRING null");
040                            runSQL("alter_column_type JournalTemplate description STRING null");
041                    }
042                    catch (SQLException sqle) {
043                            upgradeTable(
044                                    JournalArticleTable.TABLE_NAME,
045                                    JournalArticleTable.TABLE_COLUMNS,
046                                    JournalArticleTable.TABLE_SQL_CREATE,
047                                    JournalArticleTable.TABLE_SQL_ADD_INDEXES);
048    
049                            upgradeTable(
050                                    JournalStructureTable.TABLE_NAME,
051                                    JournalStructureTable.TABLE_COLUMNS,
052                                    JournalStructureTable.TABLE_SQL_CREATE,
053                                    JournalStructureTable.TABLE_SQL_ADD_INDEXES);
054    
055                            upgradeTable(
056                                    JournalTemplateTable.TABLE_NAME,
057                                    JournalTemplateTable.TABLE_COLUMNS,
058                                    JournalTemplateTable.TABLE_SQL_CREATE,
059                                    JournalTemplateTable.TABLE_SQL_ADD_INDEXES);
060                    }
061    
062                    updateStructureXsd();
063            }
064    
065            protected void updateStructureXsd() throws Exception {
066                    runSQL(
067                            "update JournalStructure set xsd = replace(CAST_TEXT(xsd), " +
068                                    "'image_gallery', 'document_library') where xsd like " +
069                                            "'%image_gallery%'");
070            }
071    
072    }