liquibase.snapshot.jvm.SchemaSnapshotGeneratorSnowflake Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
package liquibase.snapshot.jvm;
import liquibase.database.Database;
import liquibase.database.core.SnowflakeDatabase;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import liquibase.structure.DatabaseObject;
import liquibase.util.JdbcUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class SchemaSnapshotGeneratorSnowflake extends SchemaSnapshotGenerator {
@Override
public int getPriority(Class extends DatabaseObject> objectType, Database database) {
int priority = super.getPriority(objectType, database);
if (database instanceof SnowflakeDatabase) {
priority += PRIORITY_DATABASE;
}
return priority;
}
@Override
protected String[] getDatabaseSchemaNames(Database database) throws SQLException, DatabaseException {
List returnList = new ArrayList<>();
ResultSet schemas = null;
try {
schemas = ((JdbcConnection) database.getConnection()).getMetaData().getSchemas(database
.getDefaultCatalogName(), database.getDefaultSchemaName());
while (schemas.next()) {
returnList.add(JdbcUtil.getValueForColumn(schemas, "TABLE_SCHEM", database));
}
} finally {
if (schemas != null) {
schemas.close();
}
}
return returnList.toArray(new String[returnList.size()]);
}
}