in google-cloud-spanner-hibernate-dialect/src/main/java/com/google/cloud/spanner/hibernate/schema/SpannerSchemaDropper.java [49:75]
public void doDrop(
Metadata metadata,
ExecutionOptions options,
ContributableMatcher contributableInclusionFilter,
SourceDescriptor sourceDescriptor,
TargetDescriptor targetDescriptor) {
// Initialize auxiliary database objects to enable DDL statement batching.
metadata.getDatabase().addAuxiliaryDatabaseObject(new StartBatchDdl(Action.DROP));
metadata.getDatabase().addAuxiliaryDatabaseObject(new RunBatchDdl(Action.DROP));
DdlTransactionIsolator isolator = tool.getDdlTransactionIsolator(options);
try {
Connection connection = isolator.getIsolatedConnection();
// Initialize exporters with drop table dependencies so tables are dropped in the right order.
SpannerDatabaseInfo spannerDatabaseInfo =
new SpannerDatabaseInfo(metadata.getDatabase(), connection.getMetaData());
tool.getSpannerTableExporter(options).init(metadata, spannerDatabaseInfo, Action.DROP);
tool.getForeignKeyExporter(options).init(spannerDatabaseInfo);
schemaDropper.doDrop(
metadata, options, contributableInclusionFilter, sourceDescriptor, targetDescriptor);
} catch (SQLException e) {
throw new RuntimeException("Failed to update Spanner table schema.", e);
} finally {
isolator.release();
}
}