Search in sources :

Example 76 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method testTag.

@Test
public void testTag() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(completeChangeLog);
    clearDatabase(liquibase);
    liquibase = createLiquibase(completeChangeLog);
    liquibase.update(this.contexts);
    liquibase.tag("Test Tag");
}
Also used : Liquibase(liquibase.Liquibase) Test(org.junit.Test)

Example 77 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method testUnrunChangeSetsEmptyDatabase.

@Test
public void testUnrunChangeSetsEmptyDatabase() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(completeChangeLog);
    clearDatabase(liquibase);
    liquibase = createLiquibase(completeChangeLog);
    List<ChangeSet> list = liquibase.listUnrunChangeSets(new Contexts(this.contexts), new LabelExpression());
    assertTrue(list.size() > 0);
}
Also used : Liquibase(liquibase.Liquibase) LabelExpression(liquibase.LabelExpression) Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 78 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class LiquibaseChangeLogSyncSQLMojo method createLiquibase.

@Override
protected Liquibase createLiquibase(ResourceAccessor fo, Database db) throws MojoExecutionException {
    Liquibase liquibase = super.createLiquibase(fo, db);
    // Setup the output file writer
    try {
        if (!migrationSqlOutputFile.exists()) {
            // Ensure the parent directories exist
            migrationSqlOutputFile.getParentFile().mkdirs();
            // Create the actual file
            if (!migrationSqlOutputFile.createNewFile()) {
                throw new MojoExecutionException("Cannot create the migration SQL file; " + migrationSqlOutputFile.getAbsolutePath());
            }
        }
        outputWriter = getOutputWriter(migrationSqlOutputFile);
        ;
    } catch (IOException e) {
        getLog().error(e);
        throw new MojoExecutionException("Failed to create SQL output writer", e);
    }
    getLog().info("Output SQL Migration File: " + migrationSqlOutputFile.getAbsolutePath());
    return liquibase;
}
Also used : Liquibase(liquibase.Liquibase) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException)

Example 79 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class LiquibaseFutureRollbackSQL method createLiquibase.

@Override
protected Liquibase createLiquibase(ResourceAccessor fo, Database db) throws MojoExecutionException {
    Liquibase liquibase = super.createLiquibase(fo, db);
    // Setup the output file writer
    try {
        if (!outputFile.exists()) {
            // Ensure the parent directories exist
            outputFile.getParentFile().mkdirs();
            // Create the actual file
            if (!outputFile.createNewFile()) {
                throw new MojoExecutionException("Cannot create the output file; " + outputFile.getAbsolutePath());
            }
        }
        outputWriter = getOutputWriter(outputFile);
    } catch (IOException e) {
        getLog().error(e);
        throw new MojoExecutionException("Failed to create SQL output writer", e);
    }
    getLog().info("Output File: " + outputFile.getAbsolutePath());
    return liquibase;
}
Also used : Liquibase(liquibase.Liquibase) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException)

Example 80 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class LiquibaseUpdateSQL method createLiquibase.

@Override
protected Liquibase createLiquibase(ResourceAccessor fo, Database db) throws MojoExecutionException {
    Liquibase liquibase = super.createLiquibase(fo, db);
    // Setup the output file writer
    try {
        if (!migrationSqlOutputFile.exists()) {
            // Ensure the parent directories exist
            migrationSqlOutputFile.getParentFile().mkdirs();
            // Create the actual file
            if (!migrationSqlOutputFile.createNewFile()) {
                throw new MojoExecutionException("Cannot create the migration SQL file; " + migrationSqlOutputFile.getAbsolutePath());
            }
        }
        outputWriter = getOutputWriter(migrationSqlOutputFile);
    } catch (IOException e) {
        getLog().error(e);
        throw new MojoExecutionException("Failed to create SQL output writer", e);
    }
    getLog().info("Output SQL Migration File: " + migrationSqlOutputFile.getAbsolutePath());
    return liquibase;
}
Also used : Liquibase(liquibase.Liquibase) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Aggregations

Liquibase (liquibase.Liquibase)125 LiquibaseException (liquibase.exception.LiquibaseException)37 JdbcConnection (liquibase.database.jvm.JdbcConnection)35 Database (liquibase.database.Database)33 ClassLoaderResourceAccessor (liquibase.resource.ClassLoaderResourceAccessor)33 Test (org.junit.Test)30 IOException (java.io.IOException)27 Contexts (liquibase.Contexts)24 SQLException (java.sql.SQLException)23 ResourceAccessor (liquibase.resource.ResourceAccessor)14 ChangeSet (liquibase.changelog.ChangeSet)13 DatabaseException (liquibase.exception.DatabaseException)12 ValidationFailedException (liquibase.exception.ValidationFailedException)12 LabelExpression (liquibase.LabelExpression)11 Connection (java.sql.Connection)10 AbstractIntegrationTest (liquibase.dbtest.AbstractIntegrationTest)10 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)10 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)10 BuildException (org.apache.tools.ant.BuildException)10 LockException (liquibase.exception.LockException)9