Scope and limits
Version 1.0 for PostgreSQL 14+ and Hibernate ORM 7.4, with a deliberately narrow scope. What is outside is refused with a message, never guessed.
What can be mapped
Entities with the common basic types and everything Hibernate usually generates around them.
What the executor plans
It creates, renames, adds and widens. Widening means a longer VARCHAR, INTEGER to BIGINT, or a larger NUMERIC precision with the same scale.
Without a decision
Create, rename, add, widen; replace and drop indexes and unique keys.
With an approval
Drops, renames back, reverts, and dropping a unique key whose columns stay.
With a message
Arrays, collections inside embeddables, any other type change, primary key changes.
Large objects and JSON documents
Two mappings behave differently from what their annotations suggest.
Hibernate stores @Lob, Blob and Clob on PostgreSQL as large objects in oid columns. PostgreSQL does not delete them with their row. Run vacuumlo regularly; the lo_manage trigger is no option because the executor refuses triggers on managed tables.
@JdbcTypeCode(SqlTypes.JSON) maps a value to one jsonb column; on an @Embedded property the whole embeddable becomes one document. An enum or non-null property inside it would need a table check the model cannot represent, so it is refused.
Six sbt projects
Package root com.anjunar.hibernateddl. The core depends neither on Hibernate nor on a database driver.
- schema-core
- Model, validation, diff, operations.
- schema-hibernate
- @SchemaId and HibernateSchemaSource.
- schema-executor
- Transaction, planning against the stored model, history, preview.
- schema-postgresql
- SQL, catalog checks, locking and history for PostgreSQL.
- schema-integration
- HibernateSchemaMigration and the opt-in integrator.
- schema-cli
- Demo and the read-only preview command. Not published.