pub const fn cron_migration_sql() -> &'static strExpand description
Returns the SQL DDL to create the cron state table and indexes.
The DDL uses IF NOT EXISTS for idempotency — running it multiple times
is safe and produces no errors.
§Table Schema
| Column | Type | Notes |
|---|---|---|
pk_cron_state | BIGINT GENERATED ALWAYS AS IDENTITY | Trinity-style PK |
function_name | TEXT NOT NULL | Function with the cron trigger |
cron_expr | TEXT NOT NULL | Cron expression that fired |
last_fired_at | TIMESTAMPTZ NOT NULL | When the cron last fired |
next_fire_at | TIMESTAMPTZ | Computed next fire time (optional) |
fire_count | BIGINT NOT NULL DEFAULT 0 | Total number of fires |
updated_at | TIMESTAMPTZ NOT NULL DEFAULT now() | Last row update |
§Example
let sql = fraiseql_functions::migrations::cron_migration_sql();
assert!(sql.contains("_fraiseql_cron_state"));