001    /**
002     * Copyright (c) 2000-2010 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            protected void doUpgrade() throws Exception {
030                    try {
031                            runSQL(
032                                    "alter_column_type JournalArticle smallImageURL STRING null");
033                    }
034                    catch (Exception e) {
035                            UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
036                                    JournalArticleTable.TABLE_NAME,
037                                    JournalArticleTable.TABLE_COLUMNS);
038    
039                            upgradeTable.setCreateSQL(JournalArticleTable.TABLE_SQL_CREATE);
040    
041                            upgradeTable.updateTable();
042                    }
043    
044                    try {
045                            runSQL(
046                                    "alter_column_type JournalFeed targetLayoutFriendlyUrl " +
047                                    "VARCHAR(255) null");
048                    }
049                    catch (Exception e) {
050                            UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
051                                    JournalFeedTable.TABLE_NAME, JournalFeedTable.TABLE_COLUMNS);
052    
053                            upgradeTable.setCreateSQL(JournalFeedTable.TABLE_SQL_CREATE);
054    
055                            upgradeTable.updateTable();
056                    }
057    
058                    try {
059                            runSQL(
060                                    "alter_column_type JournalTemplate smallImageURL STRING null");
061                    }
062                    catch (Exception e) {
063                            UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
064                                    JournalTemplateTable.TABLE_NAME,
065                                    JournalTemplateTable.TABLE_COLUMNS);
066    
067                            upgradeTable.setCreateSQL(JournalTemplateTable.TABLE_SQL_CREATE);
068    
069                            upgradeTable.updateTable();
070                    }
071            }
072    
073    }