Maintains the monthly continuum_events partition horizon.
ensure/1 is cluster-safe and idempotent. It serializes maintenance with a
PostgreSQL advisory lock, creates a default partition when one is missing,
and creates the requested monthly partitions. If the default partition
already contains rows for a newly-created month, those rows are moved into
the month partition in the same transaction.
The database user running this operation needs permission to create and lock tables. Applications that separate migration and runtime database roles can call this API from a release task instead of enabling the optional runtime maintainer.
Summary
Functions
Ensures a future horizon of monthly event partitions.
Returns the current partition plan without changing the database.
Types
@type summary() :: %{ optional(:reason) => :maintenance_locked, status: :ok | :skipped, instance: atom() | nil, horizon_start: String.t(), horizon_end: String.t(), required: [String.t()], created: [String.t()], existing: [String.t()], moved_row_count: non_neg_integer(), default_partition: String.t() | nil, default_created?: boolean(), default_row_count: non_neg_integer() }
Functions
Ensures a future horizon of monthly event partitions.
This operation is safe to call concurrently from multiple cluster nodes.
The default lock mode waits for the current maintainer and then rechecks the
horizon. Pass lock: :try for scheduled best-effort maintenance that should
return %{status: :skipped, reason: :maintenance_locked} instead of waiting.
See plan/1 for the common options. :timeout controls the transaction
timeout and defaults to 30 seconds. :source is copied to telemetry metadata.
Returns the current partition plan without changing the database.
Options:
:instanceor:reposelects the database.:monthsis the positive future horizon, defaulting to 4 and capped at 120.:start_monthaccepts a first-of-monthDateorYYYY-MMstring. The database clock's current month is used by default.