001    /**
002     * Copyright (c) 2000-present 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.kernel.util.LoggingTimer;
019    import com.liferay.portal.upgrade.v6_1_0.util.BlogsEntryTable;
020    
021    /**
022     * @author Minhchau Dang
023     * @author Brian Wing Shun Chan
024     */
025    public class UpgradeBlogs extends UpgradeProcess {
026    
027            protected void alterTable() throws Exception {
028                    try (LoggingTimer loggingTimer = new LoggingTimer()) {
029                            runSQL("alter table BlogsEntry drop column draft");
030    
031                            alter(
032                                    BlogsEntryTable.class,
033                                    new AlterColumnType("smallImageURL", "STRING null"));
034                    }
035                    catch (Exception e) {
036                    }
037            }
038    
039            @Override
040            protected void doUpgrade() throws Exception {
041                    dropIndexes();
042    
043                    alterTable();
044            }
045    
046            protected void dropIndexes() {
047                    try (LoggingTimer loggingTimer = new LoggingTimer()) {
048                            runSQL("drop index IX_E0D90212 on BlogsEntry");
049                            runSQL("drop index IX_DA53AFD4 on BlogsEntry");
050                            runSQL("drop index IX_B88E740E on BlogsEntry");
051                    }
052                    catch (Exception e) {
053                    }
054            }
055    
056    }