Search in sources :

Example 1 with UnsupportedDatabase

use of liquibase.database.core.UnsupportedDatabase in project collect by openforis.

the class LiquidbaseDatabaseSnapshotBuilder method createSnapshot.

public synchronized DatabaseSnapshot createSnapshot(RelationalSchema relationalSchema, boolean dbSupportsFKs) throws DatabaseException {
    this.schema = relationalSchema;
    UnsupportedDatabase db = new UnsupportedDatabase();
    snapshot = new DatabaseSnapshot(db, null);
    createTables();
    createPKIndexes();
    if (dbSupportsFKs) {
        createForeignKeys();
    }
    return snapshot;
}
Also used : UnsupportedDatabase(liquibase.database.core.UnsupportedDatabase) DatabaseSnapshot(liquibase.snapshot.DatabaseSnapshot)

Example 2 with UnsupportedDatabase

use of liquibase.database.core.UnsupportedDatabase in project liquibase by liquibase.

the class DatabaseFactory method findCorrectDatabaseImplementation.

public Database findCorrectDatabaseImplementation(DatabaseConnection connection) throws DatabaseException {
    SortedSet<Database> foundDatabases = new TreeSet<>(new DatabaseComparator());
    for (Database implementedDatabase : getImplementedDatabases()) {
        if (connection instanceof OfflineConnection) {
            if (((OfflineConnection) connection).isCorrectDatabaseImplementation(implementedDatabase)) {
                foundDatabases.add(implementedDatabase);
            }
        } else {
            if (implementedDatabase.isCorrectDatabaseImplementation(connection)) {
                foundDatabases.add(implementedDatabase);
            }
        }
    }
    if (foundDatabases.isEmpty()) {
        LOG.warning("Unknown database: " + connection.getDatabaseProductName());
        UnsupportedDatabase unsupportedDB = new UnsupportedDatabase();
        unsupportedDB.setConnection(connection);
        return unsupportedDB;
    }
    Database returnDatabase;
    try {
        returnDatabase = foundDatabases.iterator().next().getClass().getConstructor().newInstance();
    } catch (Exception e) {
        throw new UnexpectedLiquibaseException(e);
    }
    returnDatabase.setConnection(connection);
    return returnDatabase;
}
Also used : UnsupportedDatabase(liquibase.database.core.UnsupportedDatabase) UnsupportedDatabase(liquibase.database.core.UnsupportedDatabase) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) DatabaseException(liquibase.exception.DatabaseException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException)

Aggregations

UnsupportedDatabase (liquibase.database.core.UnsupportedDatabase)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 DatabaseException (liquibase.exception.DatabaseException)1 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)1 DatabaseSnapshot (liquibase.snapshot.DatabaseSnapshot)1