liquibase.database.core.DerbyDatabase Java Examples

The following examples show how to use liquibase.database.core.DerbyDatabase. 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: GeometryColumnsUtils.java    From liquibase-spatial with Apache License 2.0 6 votes vote down vote up
/**
 * Indicates if the <code>GEOMETRY_COLUMNS</code> table or view exists.
 * 
 * @param database
 *           the database to check.
 * @return <code>true</code> if the table or view exists.
 */
public static boolean geometryColumnsExists(final Database database) {
   String geometryColumnsName = database.correctObjectName(
         "geometry_columns", Table.class);
   DatabaseObject example = null;
   if (database instanceof DerbyDatabase || database instanceof H2Database) {
      final Table tableExample = new Table();
      tableExample.setName(geometryColumnsName);
      tableExample.setSchema(database.getDefaultCatalogName(),
            database.getDefaultSchemaName());
      example = tableExample;
   } else if (database instanceof PostgresDatabase) {
      final View viewExample = new View();
      viewExample.setName(geometryColumnsName);
      viewExample.setSchema(database.getDefaultCatalogName(), "public");
      example = viewExample;
   }
   try {
      return example != null
            && SnapshotGeneratorFactory.getInstance().has(example, database);
   } catch (final LiquibaseException e) {
      throw new UnexpectedLiquibaseException(
            "Failed to determine if the geometry_columns table or view exists",
            e);
   }
}
 
Example #2
Source File: DropSpatialIndexChange.java    From liquibase-spatial with Apache License 2.0 6 votes vote down vote up
/**
 * Generates a {@link DropSpatialIndexStatement} followed by a {@link DropIndexStatement}, if
 * applicable. The first statement allows extra clean-up when dropping an index. The second
 * statement leverages the normal <code>DROP INDEX</code> logic.
 */
@Override
public SqlStatement[] generateStatements(final Database database) {
   final Collection<SqlStatement> statements = new ArrayList<SqlStatement>();
   // MySQL and PostgreSQL only need the normal DROP INDEX statement.
   if (!(database instanceof MySQLDatabase) && !(database instanceof PostgresDatabase)) {
      final DropSpatialIndexStatement dropSpatialIndex = new DropSpatialIndexStatement(
            this.indexName, this.catalogName, this.schemaName, this.tableName);
      statements.add(dropSpatialIndex);
   }

   // GeoDB doesn't use a tradition index structure so don't issue the normal DROP INDEX
   // statement.
   if (!(database instanceof DerbyDatabase) && !(database instanceof H2Database)) {
      final DropIndexStatement dropIndex = new DropIndexStatement(this.indexName,
            this.catalogName, this.schemaName, this.tableName, null);
      statements.add(dropIndex);
   }
   return statements.toArray(new SqlStatement[statements.size()]);
}
 
Example #3
Source File: AddGeometryColumnGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
/**
 * @see liquibase.sqlgenerator.core.AbstractSqlGenerator#supports(liquibase.statement.SqlStatement,
 *      liquibase.database.Database)
 */
@Override
public boolean supports(final AddColumnStatement statement,
      final Database database) {
   return database instanceof DerbyDatabase
         || database instanceof H2Database;
}
 
Example #4
Source File: SpatialIndexExistsPrecondition.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an example of the database object for which to check.
 *
 * @param database
 *           the database instance.
 * @param tableName
 *           the table name of the index.
 * @return the database object example.
 */
public DatabaseObject getExample(final Database database, final String tableName) {
   final Schema schema = new Schema(getCatalogName(), getSchemaName());
   final DatabaseObject example;

   // For GeoDB, the index is another table.
   if (database instanceof DerbyDatabase || database instanceof H2Database) {
      final String correctedTableName = database.correctObjectName(getHatboxTableName(),
            Table.class);
      example = new Table().setName(correctedTableName).setSchema(schema);
   } else {
      example = getIndexExample(database, schema, tableName);
   }
   return example;
}
 
Example #5
Source File: SpatialSupportedPrecondition.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
@Override
public Warnings warn(final Database database) {
   final Warnings warnings = new Warnings();
   if (!(database instanceof DerbyDatabase || database instanceof H2Database
         || database instanceof MySQLDatabase || database instanceof OracleDatabase || database instanceof PostgresDatabase)) {
      warnings.addWarning(database.getDatabaseProductName()
            + " is not supported by this extension");
   }
   return warnings;
}
 
Example #6
Source File: SpatialSupportedPrecondition.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
@Override
public ValidationErrors validate(final Database database) {
   final ValidationErrors errors = new ValidationErrors();
   if (!(database instanceof DerbyDatabase || database instanceof H2Database
         || database instanceof MySQLDatabase || database instanceof OracleDatabase || database instanceof PostgresDatabase)) {
      errors.addError(database.getDatabaseProductName() + " is not supported by this extension");
   }
   return errors;
}
 
Example #7
Source File: AddGeometryColumnGeneratorGeoDBTest.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
/**
 * Provides test data to {@link #testSupports(AddColumnStatement, Database, boolean)}.
 *
 * @return the test data.
 */
@DataProvider
public Object[][] supportsTestData() {
   final AddColumnStatement statement = new AddColumnStatement((String) null, null, null, null,
         null, null);
   return new Object[][] { new Object[] { statement, new DerbyDatabase(), true },
         new Object[] { statement, new H2Database(), true },
         new Object[] { statement, new OracleDatabase(), false }, };
}
 
Example #8
Source File: DropGeometryColumnGeneratorGeoDBTest.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
/**
 * Provides test data to {@link #testSupports(DropColumnStatement, Database, boolean)}.
 * 
 * @return the test data.
 */
@DataProvider
public Object[][] supportsTestData() {
   final DropColumnStatement statement = new DropColumnStatement(null, null, null, null);
   return new Object[][] { new Object[] { statement, new DerbyDatabase(), true },
         new Object[] { statement, new H2Database(), true },
         new Object[] { statement, new OracleDatabase(), false }, };
}
 
Example #9
Source File: DropSpatialIndexGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 4 votes vote down vote up
/**
 * @see liquibase.sqlgenerator.core.AbstractSqlGenerator#supports(liquibase.statement.SqlStatement,
 *      liquibase.database.Database)
 */
@Override
public boolean supports(final DropSpatialIndexStatement statement,
      final Database database) {
   return database instanceof DerbyDatabase || database instanceof H2Database;
}
 
Example #10
Source File: CreateSpatialTableGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 4 votes vote down vote up
/**
 * @see liquibase.sqlgenerator.core.AbstractSqlGenerator#supports(liquibase.statement.SqlStatement,
 *      liquibase.database.Database)
 */
@Override
public boolean supports(final CreateTableStatement statement, final Database database) {
   return database instanceof DerbyDatabase || database instanceof H2Database;
}
 
Example #11
Source File: SpatialInsertGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supports(final InsertStatement statement, final Database database) {
   return database instanceof DerbyDatabase || database instanceof H2Database;
}
 
Example #12
Source File: CreateSpatialIndexGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supports(final CreateSpatialIndexStatement statement, final Database database) {
   return database instanceof DerbyDatabase || database instanceof H2Database;
}
 
Example #13
Source File: SpatialUpdateGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supports(final UpdateStatement statement, final Database database) {
   return database instanceof DerbyDatabase || database instanceof H2Database;
}
 
Example #14
Source File: DropGeometryColumnGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 4 votes vote down vote up
/**
 * @see liquibase.sqlgenerator.core.AbstractSqlGenerator#supports(liquibase.statement.SqlStatement,
 *      liquibase.database.Database)
 */
@Override
public boolean supports(final DropColumnStatement statement, final Database database) {
   return database instanceof DerbyDatabase || database instanceof H2Database;
}
 
Example #15
Source File: DropSpatialTableGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 4 votes vote down vote up
/**
 * @see AbstractSqlGenerator#supports(SqlStatement, Database)
 */
@Override
public boolean supports(final DropTableStatement statement, final Database database) {
   return database instanceof DerbyDatabase || database instanceof H2Database;
}