Class SchemaHistoryRepository

java.lang.Object
com.onec.schema.SchemaHistoryRepository

public class SchemaHistoryRepository extends Object
Persistence for onec_schema_history: one row per applied schema change-set (kind SCHEMA, carrying the metadata snapshot and the DDL that was executed) and one row per executed AppMigration (kind MIGRATION, claimed via a unique constraint so concurrent instances run each migration exactly once).
  • Field Details

  • Constructor Details

    • SchemaHistoryRepository

      public SchemaHistoryRepository()
  • Method Details

    • ensure

      public void ensure(org.jdbi.v3.core.Jdbi jdbi)
    • latestSnapshotJson

      public Optional<String> latestSnapshotJson(org.jdbi.v3.core.Jdbi jdbi)
    • recordSchema

      public void recordSchema(org.jdbi.v3.core.Jdbi jdbi, String snapshotJson, List<String> appliedDdl, String description)
    • appliedMigrationVersions

      public Set<String> appliedMigrationVersions(org.jdbi.v3.core.Jdbi jdbi)
    • tryClaimMigration

      public boolean tryClaimMigration(org.jdbi.v3.core.Handle handle, String version, String description)
      Claims a migration version inside the caller's transaction. Returns false when the version is already recorded (applied earlier, or claimed concurrently by another instance — the unique constraint on (_kind, _version) arbitrates).