How it works
The publisher hooks into the Spring Boot lifecycle to read and upload the database schema once the application is ready, without affecting business logic or startup time.
Startup flow
DbSchemaPublisherEventListenerlistens for the SpringApplicationReadyEvent.- It calls
DbSchemaPublisher.publishDatabaseSchemaAsync(), which is@Asyncon a dedicated single-thread task executor (dbSchemaPublisherTaskExecutor). The upload therefore runs in the background and never blocks startup. DatabaseModelReaderopens a JDBC connection from the applicationDataSourceand reads the schema (named byjeap.archrepo.database.schema-name, defaultdata) fromDatabaseMetaData.- The result is wrapped in a
CreateOrUpdateDbSchemaDto(the system component name isspring.application.name) and posted to the archrepo atPOST /api/dbschemas. - The operation is optionally wrapped by
TracingTimerin a Micrometer span (publish-db-schema) and timer (jeap-publish-database-schema, taggedstatus=success|error) when aTracerandMeterRegistryare present.
The whole upload is best-effort: any exception is caught and logged as
Failed to publish database schema; the application keeps running.
The schema model
DatabaseModelReader (module jeap-db-schema-publisher-model-reader) maps JDBC metadata into a set of
immutable records:
| Record | Fields |
|---|---|
DatabaseSchema | name, version, tables |
Table | name, columns, foreignKeys, primaryKey |
TableColumn | name, type, nullable |
TablePrimaryKey | name, columnNames |
TableForeignKey | name, columnNames, referencedTableName, referencedColumnNames |
Foreign keys that span multiple columns are grouped by foreign-key name. The version field is the
application version resolved by AppVersionProvider from BuildProperties, then GitProperties
(git.build.version), falling back to na if neither is available.