Skip to content

Runtime enforcement (SchemaManager)

Catalogs are applied by a SchemaManager bean, enforced once on startup. It’s also injectable, so you can drive schema changes at runtime — e.g. build indexes after a bulk load, or rebuild after re-embedding:

@Component
class Reindexer(private val schema: SchemaManager) {
fun afterBulkLoad() {
schema.enforce() // idempotent: create what's missing, recreate on version change
}
fun afterReembed() {
schema.recreateAll() // brute-force: drop + recreate every declared item
}
}

enforce() is safe to call repeatedly; recreateAll() is the destructive hammer. (drivine.schema.enabled=false disables only the startup run — the bean is still there for runtime calls.)

The manager reads the catalog beans once, when it is built: a SchemaCatalog bean made later is not seen, and a later enforce() applies the same catalogs. With nothing to apply it says so at INFO — Schema management found no SchemaCatalog when none was registered, or found 2 SchemaCatalog(s), all empty: 'dice', unnamed when every one registered nothing — so that a missing index can be traced to a catalog that never arrived. Schema known only later is given to ensure, below.