HHH-18406 Drop and recreate UserDefinedTypes for schema update as well

This commit is contained in:
Marco Belladelli 2024-07-25 12:29:40 +02:00
parent 6d3ee70f72
commit 09baefba40
3 changed files with 10 additions and 2 deletions

View File

@ -59,6 +59,8 @@ import static org.hibernate.engine.config.spi.StandardConverters.STRING;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.tool.schema.UniqueConstraintSchemaUpdateStrategy.DROP_RECREATE_QUIETLY;
import static org.hibernate.tool.schema.UniqueConstraintSchemaUpdateStrategy.SKIP;
import static org.hibernate.tool.schema.internal.SchemaCreatorImpl.createUserDefinedTypes;
import static org.hibernate.tool.schema.internal.SchemaDropperImpl.dropUserDefinedTypes;
/**
* Base implementation of {@link SchemaMigrator}.
@ -195,6 +197,9 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
}
}
// Drop all UDTs
dropUserDefinedTypes( metadata, options, schemaFilter, dialect, formatter, sqlGenerationContext, targets );
// Create before-table AuxiliaryDatabaseObjects
for ( AuxiliaryDatabaseObject auxiliaryDatabaseObject : database.getAuxiliaryDatabaseObjects() ) {
if ( auxiliaryDatabaseObject.beforeTablesOnCreation()
@ -209,6 +214,9 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
}
}
// Recreate all UDTs
createUserDefinedTypes( metadata, options, schemaFilter, dialect, formatter, sqlGenerationContext, targets );
boolean tryToCreateCatalogs = false;
boolean tryToCreateSchemas = false;
if ( options.shouldManageNamespaces() ) {

View File

@ -497,7 +497,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
}
}
private static void createUserDefinedTypes(
static void createUserDefinedTypes(
Metadata metadata,
ExecutionOptions options,
SchemaFilter schemaFilter,

View File

@ -391,7 +391,7 @@ public class SchemaDropperImpl implements SchemaDropper {
}
}
private static void dropUserDefinedTypes(
static void dropUserDefinedTypes(
Metadata metadata,
ExecutionOptions options,
SchemaFilter schemaFilter,