Package liquibase.diff.output

Examples of liquibase.diff.output.DiffOutputControl


        }
        if (namespace.getBoolean("views")) {
            compareTypes.add(View.class);
        }

        final DiffToChangeLog diffToChangeLog = new DiffToChangeLog(new DiffOutputControl());
        final Database database = liquibase.getDatabase();

        final String filename = namespace.getString("output");
        if (filename != null) {
            try (PrintStream file = new PrintStream(filename, StandardCharsets.UTF_8.name())) {
View Full Code Here


        Database database = liquibase.getDatabase();

        getLog().info("Generating Change Log from database " + database.toString());
        try {
            CommandLineUtils.doGenerateChangeLog(outputChangeLogFile, database, defaultCatalogName, defaultSchemaName, StringUtils.trimToNull(diffTypes),
                    StringUtils.trimToNull(changeSetAuthor), StringUtils.trimToNull(changeSetContext), StringUtils.trimToNull(dataDir), new DiffOutputControl(outputDefaultCatalog, outputDefaultSchema, true));
            getLog().info("Output written to Change Log file, " + outputChangeLogFile);
        }
        catch (IOException e) {
            throw new LiquibaseException(e);
        }
View Full Code Here

        Database referenceDatabase = CommandLineUtils.createDatabaseObject(cl, referenceUrl, referenceUsername, referencePassword, referenceDriver, referenceDefaultCatalogName, referenceDefaultSchemaName, outputDefaultCatalog, outputDefaultSchema, null, null, propertyProviderClass, null, null);

        getLog().info("Performing Diff on database " + db.toString());
        if (diffChangeLogFile != null) {
            try {
                CommandLineUtils.doDiffToChangeLog(diffChangeLogFile, referenceDatabase, db, new DiffOutputControl(diffIncludeCatalog, diffIncludeSchema, diffIncludeTablespace).addIncludedSchema(new CatalogAndSchema(referenceDefaultCatalogName, referenceDefaultSchemaName)), StringUtils.trimToNull(diffTypes));
                getLog().info("Differences written to Change Log File, " + diffChangeLogFile);
            }
            catch (IOException e) {
                throw new LiquibaseException(e);
            }
View Full Code Here

            CompositeResourceAccessor fileOpener = new CompositeResourceAccessor(fsOpener, clOpener);

            boolean includeCatalog = Boolean.parseBoolean(getCommandParam("includeCatalog", "false"));
            boolean includeSchema = Boolean.parseBoolean(getCommandParam("includeSchema", "false"));
            boolean includeTablespace = Boolean.parseBoolean(getCommandParam("includeTablespace", "false"));
            DiffOutputControl diffOutputControl = new DiffOutputControl(includeCatalog, includeSchema, includeTablespace);

            String referenceSchemaNames = getCommandParam("schemas", null);
            CompareControl.SchemaComparison[] finalSchemaComparisons;
            CatalogAndSchema[] finalSchemas;
            if (referenceSchemaNames == null) {
                finalSchemaComparisons = new CompareControl.SchemaComparison[] {new CompareControl.SchemaComparison(new CatalogAndSchema(defaultCatalogName, defaultSchemaName), new CatalogAndSchema(defaultCatalogName, defaultSchemaName))};
                finalSchemas = new CatalogAndSchema[] {new CatalogAndSchema(defaultCatalogName, defaultSchemaName)};
            } else {
                List<CompareControl.SchemaComparison> schemaComparisons = new ArrayList<CompareControl.SchemaComparison>();
                List<CatalogAndSchema> schemas = new ArrayList<CatalogAndSchema>();
                for (String schema : referenceSchemaNames.split(",")) {
                    CatalogAndSchema correctedSchema = new CatalogAndSchema(null, schema).customize(database);
                    schemaComparisons.add(new CompareControl.SchemaComparison(correctedSchema, correctedSchema));
                    schemas.add(correctedSchema);
                    diffOutputControl.addIncludedSchema(correctedSchema);
                }
                finalSchemaComparisons  = schemaComparisons.toArray(new CompareControl.SchemaComparison[schemaComparisons.size()]);
                finalSchemas  = schemas.toArray(new CatalogAndSchema[schemas.size()]);
            }

            for (CompareControl.SchemaComparison schema : finalSchemaComparisons) {
                diffOutputControl.addIncludedSchema(schema.getReferenceSchema());
                diffOutputControl.addIncludedSchema(schema.getComparisonSchema());
            }

            if ("diff".equalsIgnoreCase(command)) {
                CommandLineUtils.doDiff(createReferenceDatabaseFromCommandParams(commandParams), database, StringUtils.trimToNull(diffTypes), finalSchemaComparisons);
                return;
View Full Code Here

    @Override
  public void executeWithLiquibaseClassloader() throws BuildException {
        Liquibase liquibase = getLiquibase();
        Database database = liquibase.getDatabase();
        CatalogAndSchema catalogAndSchema = buildCatalogAndSchema(database);
        DiffOutputControl diffOutputControl = getDiffOutputControl();
        DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diffOutputControl);

        for(ChangeLogOutputFile changeLogOutputFile : changeLogOutputFiles) {
            String encoding = getOutputEncoding(changeLogOutputFile);
            PrintStream printStream = null;
View Full Code Here

    private CatalogAndSchema buildCatalogAndSchema(Database database) {
        return new CatalogAndSchema(database.getDefaultCatalogName(), database.getDefaultSchemaName());
    }

    private DiffOutputControl getDiffOutputControl() {
        return new DiffOutputControl(includeCatalog, includeSchema, includeTablespace);
    }
View Full Code Here

            try {
                FileResource outputFile = changeLogOutputFile.getOutputFile();
                ChangeLogSerializer changeLogSerializer = changeLogOutputFile.getChangeLogSerializer();
                printStream = new PrintStream(outputFile.getOutputStream(), true, encoding);
                DiffResult diffResult = getDiffResult();
                DiffOutputControl diffOutputControl = getDiffOutputControl();
                DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diffResult, diffOutputControl);
                diffToChangeLog.print(printStream, changeLogSerializer);
            } catch (UnsupportedEncodingException e) {
                throw new BuildException("Unable to diff databases to change log file. Encoding [" + encoding + "] is not supported.", e);
            } catch (IOException e) {
View Full Code Here

        String encoding = changeLogOutputFile.getEncoding();
        return (encoding == null) ? getDefaultOutputEncoding() : encoding;
    }

    private DiffOutputControl getDiffOutputControl() {
        return new DiffOutputControl(includeCatalog, includeSchema, includeTablespace);
    }
View Full Code Here

                throw new UnexpectedLiquibaseException(e);
            }

          final long changeSetStarted = System.currentTimeMillis();
          DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(new EmptyDatabaseSnapshot(this), snapshot, new CompareControl(snapshot.getSnapshotControl().getTypesToInclude()));
            List<ChangeSet> changeSets = new DiffToChangeLog(diffResult, new DiffOutputControl(true, true, false).addIncludedSchema(schemaToDrop)).generateChangeSets();
          LogFactory.getLogger().debug(String.format("ChangeSet to Remove Database Objects generated in %d ms.", System.currentTimeMillis() - changeSetStarted));

            final boolean reEnableFK = supportsForeignKeyDisable() && disableForeignKeyChecks();
            try {
                for (ChangeSet changeSet : changeSets) {
View Full Code Here

    }

    private String toChangeLog(DiffResult diffResult) throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(out, true, "UTF-8");
        DiffOutputControl diffOutputControl = new DiffOutputControl();
        diffOutputControl.setIncludeCatalog(false);
        diffOutputControl.setIncludeSchema(false);
        DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diffResult,
                diffOutputControl);
        diffToChangeLog.print(printStream);
        printStream.close();
        return out.toString("UTF-8");
View Full Code Here

TOP

Related Classes of liquibase.diff.output.DiffOutputControl

Copyright © 2018 www.massapicom. 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.