001    /**
002     * Copyright (c) 2000-2011 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_0_0;
016    
017    import com.liferay.portal.kernel.upgrade.UpgradeProcess;
018    import com.liferay.portal.kernel.upgrade.util.UpgradeTable;
019    import com.liferay.portal.kernel.upgrade.util.UpgradeTableFactoryUtil;
020    import com.liferay.portal.upgrade.v6_0_0.util.JournalArticleTable;
021    import com.liferay.portal.upgrade.v6_0_0.util.JournalFeedTable;
022    import com.liferay.portal.upgrade.v6_0_0.util.JournalTemplateTable;
023    
024    /**
025     * @author Zsigmond Rab
026     */
027    public class UpgradeJournal extends UpgradeProcess {
028    
029            @Override
030            protected void doUpgrade() throws Exception {
031                    try {
032                            runSQL(
033                                    "alter_column_type JournalArticle smallImageURL STRING null");
034                    }
035                    catch (Exception e) {
036                            UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
037                                    JournalArticleTable.TABLE_NAME,
038                                    JournalArticleTable.TABLE_COLUMNS);
039    
040                            upgradeTable.setCreateSQL(JournalArticleTable.TABLE_SQL_CREATE);
041                            upgradeTable.setIndexesSQL(
042                                    JournalArticleTable.TABLE_SQL_ADD_INDEXES);
043    
044                            upgradeTable.updateTable();
045                    }
046    
047                    try {
048                            runSQL(
049                                    "alter_column_type JournalFeed targetLayoutFriendlyUrl " +
050                                            "VARCHAR(255) null");
051                    }
052                    catch (Exception e) {
053                            UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
054                                    JournalFeedTable.TABLE_NAME, JournalFeedTable.TABLE_COLUMNS);
055    
056                            upgradeTable.setCreateSQL(JournalFeedTable.TABLE_SQL_CREATE);
057                            upgradeTable.setIndexesSQL(JournalFeedTable.TABLE_SQL_ADD_INDEXES);
058    
059                            upgradeTable.updateTable();
060                    }
061    
062                    try {
063                            runSQL(
064                                    "alter_column_type JournalTemplate smallImageURL STRING null");
065                    }
066                    catch (Exception e) {
067                            UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
068                                    JournalTemplateTable.TABLE_NAME,
069                                    JournalTemplateTable.TABLE_COLUMNS);
070    
071                            upgradeTable.setCreateSQL(JournalTemplateTable.TABLE_SQL_CREATE);
072                            upgradeTable.setIndexesSQL(
073                                    JournalTemplateTable.TABLE_SQL_ADD_INDEXES);
074    
075                            upgradeTable.updateTable();
076                    }
077            }
078    
079    }