Package org.javalite.db_migrator.maven

Source Code of org.javalite.db_migrator.maven.MigrateMojo

package org.javalite.db_migrator.maven;

import org.apache.maven.plugin.*;
import org.javalite.activejdbc.Base;
import org.javalite.db_migrator.MigrationManager;

/**
* Migrate to latest schema version.
* <p/>
*
* @goal migrate
*/
public class MigrateMojo extends AbstractMigrationMojo {

    public void executeMojo() throws MojoExecutionException {
        getLog().info("Migrating " + getUrl() + " using migrations at " + getMigrationsPath());
        try{
            Base.open(getDriver(), getUrl(), getUsername(), getPassword());
            new MigrationManager(getMigrationsPath()).migrate(getLog(), getEncoding());
        }catch(Exception e){
            throw new MojoExecutionException("Failed to migrate database " + getUrl(), e);
        }
        finally {
            Base.close(true);
        }
    }
}
TOP

Related Classes of org.javalite.db_migrator.maven.MigrateMojo

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.