Search in sources :

Example 51 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 52 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 53 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 54 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 55 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)59 Test (org.junit.Test)37 Contexts (liquibase.Contexts)12 LiquibaseException (liquibase.exception.LiquibaseException)10 ValidationFailedException (liquibase.exception.ValidationFailedException)9 BuildException (org.apache.tools.ant.BuildException)9 IOException (java.io.IOException)8 Database (liquibase.database.Database)7 DatabaseSnapshot (liquibase.snapshot.DatabaseSnapshot)7 SnapshotControl (liquibase.snapshot.SnapshotControl)7 CatalogAndSchema (liquibase.CatalogAndSchema)6 LabelExpression (liquibase.LabelExpression)6 AbstractIntegrationTest (liquibase.dbtest.AbstractIntegrationTest)6 Namespace (net.sourceforge.argparse4j.inf.Namespace)6 Date (java.util.Date)5 JdbcConnection (liquibase.database.jvm.JdbcConnection)5 CompareControl (liquibase.diff.compare.CompareControl)5 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 FileResource (org.apache.tools.ant.types.resources.FileResource)5