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.v5_2_5_to_6_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.v5_2_5_to_6_0_0.util.WikiPageResourceTable;
021    import com.liferay.portal.upgrade.v5_2_5_to_6_0_0.util.WikiPageTable;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class UpgradeWiki extends UpgradeProcess {
027    
028            protected void doUpgrade() throws Exception {
029                    try {
030                            runSQL("alter_column_type WikiPage parentTitle varchar(255) null");
031                            runSQL(
032                                    "alter_column_type WikiPage redirectTitle varchar(255) null");
033                    }
034                    catch (Exception e) {
035    
036                            // WikiPage
037    
038                            UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
039                                    WikiPageTable.TABLE_NAME, WikiPageTable.TABLE_COLUMNS);
040    
041                            upgradeTable.setCreateSQL(WikiPageTable.TABLE_SQL_CREATE);
042    
043                            upgradeTable.updateTable();
044                    }
045    
046                    try {
047                            runSQL(
048                                    "alter_column_type WikiPageResource title varchar(255) null");
049                    }
050                    catch (Exception e) {
051    
052                            // WikiPageResource
053    
054                            UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
055                                    WikiPageResourceTable.TABLE_NAME,
056                                    WikiPageResourceTable.TABLE_COLUMNS);
057    
058                            upgradeTable.setCreateSQL(WikiPageResourceTable.TABLE_SQL_CREATE);
059    
060                            upgradeTable.updateTable();
061                    }
062            }
063    
064    }