private void generateChangeLog(final Database database, final CatalogAndSchema catalogAndSchema, final DiffToChangeLog changeLogWriter, PrintStream outputStream, final Set<Class<? extends DatabaseObject>> compareTypes) throws DatabaseException, IOException, ParserConfigurationException { @SuppressWarnings("unchecked") final SnapshotControl snapshotControl = new SnapshotControl(database, compareTypes.toArray(new Class[compareTypes.size()])); final CompareControl compareControl = new CompareControl(new CompareControl.SchemaComparison[]{ new CompareControl.SchemaComparison(catalogAndSchema, catalogAndSchema)}, compareTypes); final CatalogAndSchema[] compareControlSchemas = compareControl .getSchemas(CompareControl.DatabaseRole.REFERENCE); try { final DatabaseSnapshot referenceSnapshot = SnapshotGeneratorFactory.getInstance() .createSnapshot(compareControlSchemas, database, snapshotControl); final DatabaseSnapshot comparisonSnapshot = SnapshotGeneratorFactory.getInstance() .createSnapshot(compareControlSchemas, null, snapshotControl); final DiffResult diffResult = DiffGeneratorFactory.getInstance() .compare(referenceSnapshot, comparisonSnapshot, compareControl); changeLogWriter.setDiffResult(diffResult); changeLogWriter.print(outputStream); } catch (InvalidExampleException e) { throw new UnexpectedLiquibaseException(e); } }
@Override protected String convertToPath(String string) { if (this.baseDirectory == null) { return string; } else { try { return new File(string).getCanonicalPath(); } catch (IOException e) { throw new UnexpectedLiquibaseException(e); } } } }
@Override protected String convertToPath(String string) { if (this.baseDirectory == null) { return string; } else { try { return new File(string).getCanonicalPath(); } catch (IOException e) { throw new UnexpectedLiquibaseException(e); } } } }
public void configureFieldsAndValues(ResourceAccessor fo) throws MojoExecutionException, MojoFailureException { // Load the properties file if there is one, but only for values that the user has not // already specified. if (propertyFile != null) { getLog().info("Parsing Liquibase Properties File"); getLog().info(" File: " + propertyFile); InputStream is; try { is = StreamUtil.singleInputStream(propertyFile, fo); } catch (IOException e) { throw new UnexpectedLiquibaseException(e); } if (is == null) { throw new MojoFailureException("Failed to resolve the properties file."); } parsePropertiesFile(is); getLog().info(MavenUtils.LOG_SEPARATOR); } }
public Class findClass(Class requiredInterface) throws ServiceNotFoundException { Class[] classes = findClasses(requiredInterface); if (PrioritizedService.class.isAssignableFrom(requiredInterface)) { PrioritizedService returnObject = null; for (Class clazz : classes) { PrioritizedService newInstance; try { newInstance = (PrioritizedService) clazz.newInstance(); } catch (Exception e) { throw new UnexpectedLiquibaseException(e); } if (returnObject == null || newInstance.getPriority() > returnObject.getPriority()) { returnObject = newInstance; } } if (returnObject == null) { throw new ServiceNotFoundException("Could not find implementation of " + requiredInterface.getName()); } return returnObject.getClass(); } if (classes.length != 1) { throw new ServiceNotFoundException("Could not find unique implementation of " + requiredInterface.getName() + ". Found " + classes.length + " implementations"); } return classes[0]; }
@Override protected void performLiquibaseTask(Liquibase liquibase) throws LiquibaseException { try { liquibase.reportStatus(true, new Contexts(contexts), new LabelExpression(labels), new OutputStreamWriter(System.out, LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class).getOutputEncoding())); } catch (UnsupportedEncodingException e) { throw new UnexpectedLiquibaseException(e); } }
@Override public void setConnection(DatabaseConnection conn) { super.setConnection(conn); try { LOG.info("Reading hibernate configuration " + getConnection().getURL()); this.metadata = buildMetadata(); afterSetup(); } catch (DatabaseException e) { throw new UnexpectedLiquibaseException(e); } }
@PostConstruct public void onStartup() { log.info(LogType.LOG, "Booting Liquibase " + LiquibaseUtil.getBuildVersion()); String hostName; try { hostName = NetUtil.getLocalHostName(); } catch (Exception e) { log.warning(LogType.LOG, "Cannot find hostname: " + e.getMessage()); log.debug(LogType.LOG, "", e); return; } LiquibaseConfiguration liquibaseConfiguration = LiquibaseConfiguration.getInstance(); if (!liquibaseConfiguration.getConfiguration(GlobalConfiguration.class).getShouldRun()) { log.info(LogType.LOG, String.format("Liquibase did not run on %s because %s was set to false.", hostName, liquibaseConfiguration.describeValueLookupLogic( GlobalConfiguration.class, GlobalConfiguration.SHOULD_RUN) )); return; } initialized = true; try { performUpdate(); } catch (LiquibaseException e) { throw new UnexpectedLiquibaseException(e); } }
throw new UnexpectedLiquibaseException( "CREATE TABLE not found; unable to ensure ENGINE=INNODB for table " + statement.getTableName());
DiffOutputControl diffOutputControl = new DiffOutputControl(outputDefaultCatalog, outputDefaultSchema, true, null); if ((diffExcludeObjects != null) && (diffIncludeObjects != null)) { throw new UnexpectedLiquibaseException("Cannot specify both excludeObjects and includeObjects");
private void generateChangeLog(final Database database, final CatalogAndSchema catalogAndSchema, final DiffToChangeLog changeLogWriter, PrintStream outputStream, final Set<Class<? extends DatabaseObject>> compareTypes) throws DatabaseException, IOException, ParserConfigurationException { @SuppressWarnings({"unchecked", "rawtypes"}) final SnapshotControl snapshotControl = new SnapshotControl(database, compareTypes.toArray(new Class[compareTypes.size()])); final CompareControl compareControl = new CompareControl(new CompareControl.SchemaComparison[]{ new CompareControl.SchemaComparison(catalogAndSchema, catalogAndSchema)}, compareTypes); final CatalogAndSchema[] compareControlSchemas = compareControl .getSchemas(CompareControl.DatabaseRole.REFERENCE); try { final DatabaseSnapshot referenceSnapshot = SnapshotGeneratorFactory.getInstance() .createSnapshot(compareControlSchemas, database, snapshotControl); final DatabaseSnapshot comparisonSnapshot = SnapshotGeneratorFactory.getInstance() .createSnapshot(compareControlSchemas, null, snapshotControl); final DiffResult diffResult = DiffGeneratorFactory.getInstance() .compare(referenceSnapshot, comparisonSnapshot, compareControl); changeLogWriter.setDiffResult(diffResult); changeLogWriter.print(outputStream); } catch (InvalidExampleException e) { throw new UnexpectedLiquibaseException(e); } }
DiffOutputControl diffOutputControl = new DiffOutputControl(diffIncludeCatalog, diffIncludeSchema, diffIncludeTablespace, null).addIncludedSchema(new CatalogAndSchema(referenceDefaultCatalogName, referenceDefaultSchemaName)); if ((diffExcludeObjects != null) && (diffIncludeObjects != null)) { throw new UnexpectedLiquibaseException("Cannot specify both excludeObjects and includeObjects");