HHH-7472 - Introduce a "schema management" service
This commit is contained in:
parent
c782548172
commit
392f08fbd6
|
@ -35,6 +35,7 @@ import org.hibernate.metamodel.spi.relational.ForeignKey;
|
||||||
import org.hibernate.metamodel.spi.relational.Index;
|
import org.hibernate.metamodel.spi.relational.Index;
|
||||||
import org.hibernate.metamodel.spi.relational.InitCommand;
|
import org.hibernate.metamodel.spi.relational.InitCommand;
|
||||||
import org.hibernate.metamodel.spi.relational.Schema;
|
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.Table;
|
||||||
import org.hibernate.metamodel.spi.relational.UniqueKey;
|
import org.hibernate.metamodel.spi.relational.UniqueKey;
|
||||||
import org.hibernate.service.schema.spi.SchemaCreator;
|
import org.hibernate.service.schema.spi.SchemaCreator;
|
||||||
|
@ -73,6 +74,9 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||||
for ( Table table : schema.getTables() ) {
|
for ( Table table : schema.getTables() ) {
|
||||||
applySqlStrings( table, targets, dialect, exportIdentifiers );
|
applySqlStrings( table, targets, dialect, exportIdentifiers );
|
||||||
}
|
}
|
||||||
|
for ( Sequence sequence : schema.getSequences() ) {
|
||||||
|
applySqlStrings( sequence, targets, dialect, exportIdentifiers );
|
||||||
|
}
|
||||||
|
|
||||||
// todo : allow stuff like user datatypes.
|
// todo : allow stuff like user datatypes.
|
||||||
// maybe reusing AuxiliaryDatabaseObject as the general vehicle, but adding a notion of where
|
// maybe reusing AuxiliaryDatabaseObject as the general vehicle, but adding a notion of where
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.hibernate.metamodel.spi.relational.Exportable;
|
||||||
import org.hibernate.metamodel.spi.relational.ForeignKey;
|
import org.hibernate.metamodel.spi.relational.ForeignKey;
|
||||||
import org.hibernate.metamodel.spi.relational.Index;
|
import org.hibernate.metamodel.spi.relational.Index;
|
||||||
import org.hibernate.metamodel.spi.relational.Schema;
|
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.Table;
|
||||||
import org.hibernate.metamodel.spi.relational.UniqueKey;
|
import org.hibernate.metamodel.spi.relational.UniqueKey;
|
||||||
import org.hibernate.service.schema.spi.SchemaDropper;
|
import org.hibernate.service.schema.spi.SchemaDropper;
|
||||||
|
@ -64,18 +65,14 @@ public class SchemaDropperImpl implements SchemaDropper {
|
||||||
final Set<String> exportIdentifiers = new HashSet<String>( 50 );
|
final Set<String> exportIdentifiers = new HashSet<String>( 50 );
|
||||||
|
|
||||||
for ( Schema schema : database.getSchemas() ) {
|
for ( Schema schema : database.getSchemas() ) {
|
||||||
if ( dropSchemas ) {
|
// NOTE : init commands are irrelevant for dropping...
|
||||||
// todo : add dialect method for getting a DROP SCHEMA command and use it here
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( Table table : schema.getTables() ) {
|
for ( AuxiliaryDatabaseObject auxiliaryDatabaseObject : database.getAuxiliaryDatabaseObjects() ) {
|
||||||
applySqlStrings( table, targets, dialect, exportIdentifiers );
|
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() ) {
|
for ( Table table : schema.getTables() ) {
|
||||||
if ( ! dialect.supportsUniqueConstraintInCreateAlterTable() ) {
|
if ( ! dialect.supportsUniqueConstraintInCreateAlterTable() ) {
|
||||||
for ( UniqueKey uniqueKey : table.getUniqueKeys() ) {
|
for ( UniqueKey uniqueKey : table.getUniqueKeys() ) {
|
||||||
|
@ -95,15 +92,18 @@ public class SchemaDropperImpl implements SchemaDropper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applySqlStrings( table, targets, dialect, exportIdentifiers );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( AuxiliaryDatabaseObject auxiliaryDatabaseObject : database.getAuxiliaryDatabaseObjects() ) {
|
for ( Sequence sequence : schema.getSequences() ) {
|
||||||
if ( auxiliaryDatabaseObject.appliesToDialect( dialect ) ) {
|
applySqlStrings( sequence, targets, dialect, exportIdentifiers );
|
||||||
applySqlStrings( auxiliaryDatabaseObject, 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 ) {
|
for ( Target target : targets ) {
|
||||||
|
|
Loading…
Reference in New Issue