liquibase.configuration.LiquibaseConfiguration Java Examples

The following examples show how to use liquibase.configuration.LiquibaseConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SqlTestUtil.java    From kork with Apache License 2.0 6 votes vote down vote up
public static void cleanupDb(DSLContext context) {
  String schema = context.select(currentSchema()).fetch().getValue(0, 0).toString();

  GlobalConfiguration configuration =
      LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class);

  context.execute("set foreign_key_checks=0");
  context.meta().getTables().stream()
      .filter(
          table ->
              table.getType().isTable()
                  && table.getSchema().getName().equals(schema)
                  && !table.getName().equals(configuration.getDatabaseChangeLogTableName())
                  && !table.getName().equals(configuration.getDatabaseChangeLogLockTableName()))
      .forEach(
          table -> {
            context.truncate(table.getName()).execute();
          });
  context.execute("set foreign_key_checks=1");
}
 
Example #2
Source File: LiquibaseExtensionConfigFixture.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public void assertDefaultConfigurationSettings(LiquibaseConfig configuration) {

        assertEquals(configuration.changeLog, LiquibaseDataSourceBuildTimeConfig.defaultConfig().changeLog);

        GlobalConfiguration globalConfiguration = LiquibaseConfiguration.getInstance()
                .getConfiguration(GlobalConfiguration.class);
        assertEquals(configuration.databaseChangeLogTableName,
                globalConfiguration.getDatabaseChangeLogTableName());
        assertEquals(configuration.databaseChangeLogLockTableName,
                globalConfiguration.getDatabaseChangeLogLockTableName());
        assertEquals(configuration.liquibaseTablespaceName.orElse(null), globalConfiguration.getLiquibaseTablespaceName());
        assertEquals(configuration.liquibaseCatalogName.orElse(null), globalConfiguration.getLiquibaseCatalogName());
        assertEquals(configuration.liquibaseSchemaName.orElse(null), globalConfiguration.getLiquibaseSchemaName());

    }
 
Example #3
Source File: AbstractJdbcDatabase.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String getDatabaseChangeLogTableName() {
    if (databaseChangeLogTableName != null) {
        return databaseChangeLogTableName;
    }

    return LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class).getDatabaseChangeLogTableName();
}
 
Example #4
Source File: AbstractJdbcDatabase.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String getDatabaseChangeLogLockTableName() {
    if (databaseChangeLogLockTableName != null) {
        return databaseChangeLogLockTableName;
    }

    return LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class).getDatabaseChangeLogLockTableName();
}
 
Example #5
Source File: AbstractJdbcDatabase.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String getLiquibaseTablespaceName() {
    if (liquibaseTablespaceName != null) {
        return liquibaseTablespaceName;
    }

    return LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class).getLiquibaseTablespaceName();
}
 
Example #6
Source File: AbstractJdbcDatabase.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String getLiquibaseCatalogName() {
    if (liquibaseCatalogName != null) {
        return liquibaseCatalogName;
    }

    ConfigurationProperty configuration = LiquibaseConfiguration.getInstance().getProperty(GlobalConfiguration.class, GlobalConfiguration.LIQUIBASE_CATALOG_NAME);
    if (configuration.getWasOverridden()) {
        return configuration.getValue(String.class);
    }

    return getDefaultCatalogName();
}
 
Example #7
Source File: AbstractJdbcDatabase.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String getLiquibaseSchemaName() {
    if (liquibaseSchemaName != null) {
        return liquibaseSchemaName;
    }

    ConfigurationProperty configuration = LiquibaseConfiguration.getInstance().getProperty(GlobalConfiguration.class, GlobalConfiguration.LIQUIBASE_SCHEMA_NAME);
    if (configuration.getWasOverridden()) {
        return configuration.getValue(String.class);
    }

    return getDefaultSchemaName();
}
 
Example #8
Source File: ModelDBHibernateUtil.java    From modeldb with Apache License 2.0 5 votes vote down vote up
private static void createTablesLiquibaseMigration(MetadataSources metaDataSrc)
    throws LiquibaseException, SQLException, InterruptedException {
  // Get database connection
  try (Connection con =
      metaDataSrc.getServiceRegistry().getService(ConnectionProvider.class).getConnection()) {
    JdbcConnection jdbcCon = new JdbcConnection(con);

    // Overwrite default liquibase table names by custom
    GlobalConfiguration liquibaseConfiguration =
        LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class);
    liquibaseConfiguration.setDatabaseChangeLogLockWaitTime(1L);

    // Initialize Liquibase and run the update
    Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(jdbcCon);
    String rootPath = System.getProperty(ModelDBConstants.userDir);
    rootPath = rootPath + "\\src\\main\\resources\\liquibase\\db-changelog-1.0.xml";
    Liquibase liquibase = new Liquibase(rootPath, new FileSystemResourceAccessor(), database);

    boolean liquibaseExecuted = false;
    while (!liquibaseExecuted) {
      try {
        liquibase.update(new Contexts(), new LabelExpression());
        liquibaseExecuted = true;
      } catch (LockException ex) {
        LOGGER.warn(
            "ModelDBHibernateUtil createTablesLiquibaseMigration() getting LockException ", ex);
        releaseLiquibaseLock(metaDataSrc);
      }
    }
  }
}