HHH-7472 - Introduce a "schema management" service

This commit is contained in:
Steve Ebersole 2012-08-13 17:49:10 -05:00
parent c782548172
commit 392f08fbd6
2 changed files with 18 additions and 14 deletions

View File

@ -35,6 +35,7 @@ import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.Index;
import org.hibernate.metamodel.spi.relational.InitCommand;
import org.hibernate.metamodel.spi.relational.Schema;
import org.hibernate.metamodel.spi.relational.Sequence;
import org.hibernate.metamodel.spi.relational.Table;
import org.hibernate.metamodel.spi.relational.UniqueKey;
import org.hibernate.service.schema.spi.SchemaCreator;
@ -73,6 +74,9 @@ public class SchemaCreatorImpl implements SchemaCreator {
for ( Table table : schema.getTables() ) {
applySqlStrings( table, targets, dialect, exportIdentifiers );
}
for ( Sequence sequence : schema.getSequences() ) {
applySqlStrings( sequence, targets, dialect, exportIdentifiers );
}
// todo : allow stuff like user datatypes.
// maybe reusing AuxiliaryDatabaseObject as the general vehicle, but adding a notion of where

View File

@ -34,6 +34,7 @@ import org.hibernate.metamodel.spi.relational.Exportable;
import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.Index;
import org.hibernate.metamodel.spi.relational.Schema;
import org.hibernate.metamodel.spi.relational.Sequence;
import org.hibernate.metamodel.spi.relational.Table;
import org.hibernate.metamodel.spi.relational.UniqueKey;
import org.hibernate.service.schema.spi.SchemaDropper;
@ -64,17 +65,13 @@ public class SchemaDropperImpl implements SchemaDropper {
final Set<String> exportIdentifiers = new HashSet<String>( 50 );
for ( Schema schema : database.getSchemas() ) {
if ( dropSchemas ) {
// todo : add dialect method for getting a DROP SCHEMA command and use it here
}
// NOTE : init commands are irrelevant for dropping...
for ( Table table : schema.getTables() ) {
applySqlStrings( table, targets, dialect, exportIdentifiers );
for ( AuxiliaryDatabaseObject auxiliaryDatabaseObject : database.getAuxiliaryDatabaseObjects() ) {
if ( auxiliaryDatabaseObject.appliesToDialect( dialect ) ) {
applySqlStrings( auxiliaryDatabaseObject, targets, dialect, exportIdentifiers );
}
}
// todo : allow stuff like user datatypes.
// maybe reusing AuxiliaryDatabaseObject as the general vehicle, but adding a notion of where
// it needs to be in terms of creation?
for ( Table table : schema.getTables() ) {
if ( ! dialect.supportsUniqueConstraintInCreateAlterTable() ) {
@ -95,15 +92,18 @@ public class SchemaDropperImpl implements SchemaDropper {
}
}
}
applySqlStrings( table, targets, dialect, exportIdentifiers );
}
for ( AuxiliaryDatabaseObject auxiliaryDatabaseObject : database.getAuxiliaryDatabaseObjects() ) {
if ( auxiliaryDatabaseObject.appliesToDialect( dialect ) ) {
applySqlStrings( auxiliaryDatabaseObject, targets, dialect, exportIdentifiers );
}
for ( Sequence sequence : schema.getSequences() ) {
applySqlStrings( sequence, targets, dialect, exportIdentifiers );
}
if ( dropSchemas ) {
// todo : add dialect method for getting a DROP SCHEMA command and use it here
}
// NOT : init commands are irrelevant for dropping...
}
for ( Target target : targets ) {