Package com.dotmarketing.startup.runonce

Source Code of com.dotmarketing.startup.runonce.Task00850DropOldFilesConstraintInWorkflow

package com.dotmarketing.startup.runonce;

import java.sql.SQLException;

import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.DbConnectionFactory;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotRuntimeException;
import com.dotmarketing.startup.StartupTask;

/**
*
*
* @author Daniel Silva
*/
public class Task00850DropOldFilesConstraintInWorkflow implements StartupTask {

    public boolean forceRun() {
        return true;
    }

    void dropConstraint() throws SQLException {
        DotConnect dc = new DotConnect();
        String alterSql = "";
        if (DbConnectionFactory.isMySql())
          alterSql = "alter table workflowtask_files drop foreign key FK_task_file_inode ";
        else
          alterSql = "alter table workflowtask_files drop constraint FK_task_file_inode ";

        dc.executeStatement(alterSql);

    }


    public void executeUpgrade() throws DotDataException, DotRuntimeException {
        try {
            DbConnectionFactory.getConnection().setAutoCommit(true);
        } catch (SQLException e) {
            throw new DotDataException(e.getMessage(), e);
        }
        try {
          dropConstraint();
        } catch (Exception ex) {
            throw new DotRuntimeException(ex.getMessage(), ex);
        }
    }


}
TOP

Related Classes of com.dotmarketing.startup.runonce.Task00850DropOldFilesConstraintInWorkflow

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.