Enum Class SchemaInitialization

java.lang.Object
java.lang.Enum<SchemaInitialization>
io.axoniq.framework.postgresql.SchemaInitialization
All Implemented Interfaces:
Serializable, Comparable<SchemaInitialization>, Constable

public enum SchemaInitialization extends Enum<SchemaInitialization>
Controls whether and how PostgresqlEventStorageEngine ensures its PostgreSQL schema (tables, sequence, indices, and internal migrations) is present when it is constructed.

Writing events against a schema that is not fully up to date can corrupt data in ways that are hard to recover from -- an incomplete schema can silently produce corrupted or incomplete data instead of failing outright. The options below trade off startup cost and self-healing behavior against that risk.

Since:
5.4.0
Author:
John Hendrikx
  • Enum Constant Details

    • CREATE_IF_MISSING

      public static final SchemaInitialization CREATE_IF_MISSING
      Checks whether the schema is complete, and creates or repairs whatever is missing (tables, sequence, indices, and internal migrations). This is the default.

      When the schema is already complete, this only performs cheap existence checks and does not lock any of the event store's tables. When something is missing, the (idempotent) creation statements run, which do briefly lock the affected tables.

    • VALIDATE

      public static final SchemaInitialization VALIDATE
      Checks whether the schema is complete, and fails construction with an IllegalStateException if it is not. Never creates or modifies anything.

      Use this when schema changes are managed out-of-band (e.g. by a dedicated migration step or a database administrator) and an incomplete schema should be treated as a startup failure rather than something the application silently repairs.

    • SKIP

      public static final SchemaInitialization SKIP
      Skips all schema checks. The schema is assumed to already be complete and correct.

      This avoids any database round trip or locking at construction time, but writing events against a schema that is not actually complete can corrupt data, as described in this enum's class-level documentation. Only use this once the schema is known to be up to date, for example after a rolling deployment where earlier instances have already migrated it.

  • Method Details

    • values

      public static SchemaInitialization[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static SchemaInitialization valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null