Punk-Queue

 view release on metacpan or  search on metacpan

include/pq_migrate_pg.h  view on Meta::CPAN

"    attempts INTEGER NOT NULL DEFAULT 1,\n"
"    tz       TEXT    NOT NULL DEFAULT 'UTC',\n"
"    catchup  TEXT    NOT NULL DEFAULT 'once',\n"
"    enabled  INTEGER NOT NULL DEFAULT 1,\n"
"    last_run DOUBLE PRECISION,\n"
"    next_run DOUBLE PRECISION NOT NULL,\n"
"    last_job BIGINT,\n"
"    created  DOUBLE PRECISION NOT NULL,\n"
"    updated  DOUBLE PRECISION NOT NULL\n"
")\n"
"-- @@\n"
/* THE index - see PQ_SQLITE_UP for why delayed and parents_left are not
 * in it. */
"CREATE INDEX pq_jobs_ready ON pq_jobs (queue, priority DESC, id)\n"
"    WHERE state = 'inactive'\n"
"-- @@\n"
"CREATE INDEX pq_jobs_delayed ON pq_jobs (delayed) WHERE state = 'inactive'\n"
"-- @@\n"
"CREATE INDEX pq_jobs_gc ON pq_jobs (state, finished)\n"
"-- @@\n"
"CREATE INDEX pq_jobs_expires ON pq_jobs (expires) WHERE state = 'inactive'\n"
"-- @@\n"
"CREATE INDEX pq_jobs_worker ON pq_jobs (worker) WHERE state = 'active'\n"
"-- @@\n"
"CREATE INDEX pq_jobs_task ON pq_jobs (task, state)\n"
"-- @@\n"
"CREATE UNIQUE INDEX pq_jobs_lock_key ON pq_jobs (lock_key)\n"
"    WHERE lock_key IS NOT NULL AND state IN ('inactive', 'active')\n"
"-- @@\n"
"CREATE INDEX pq_deps_parent ON pq_job_deps (parent_id)\n"
"-- @@\n"
"CREATE UNIQUE INDEX pq_locks_name ON pq_locks (name) WHERE owner IS NOT NULL\n"
"-- @@\n"
"CREATE INDEX pq_locks_expires ON pq_locks (expires)\n"
"-- @@\n"
"CREATE INDEX pq_crons_due ON pq_crons (next_run) WHERE enabled = 1\n"
"-- @@\n"
/* Storing epoch seconds buys identical binds and comparisons on both
 * backends, and costs readability at a psql prompt. This view is the
 * apology: SELECT * FROM pq_jobs_human is what a human wants at 3am. */
"CREATE VIEW pq_jobs_human AS SELECT\n"
"    id, task, queue, state, priority, attempts, retries, parents_left,\n"
"    to_timestamp(created)  AS created,\n"
"    to_timestamp(delayed)  AS delayed,\n"
"    to_timestamp(started)  AS started,\n"
"    to_timestamp(finished) AS finished,\n"
"    to_timestamp(retried)  AS retried,\n"
"    to_timestamp(expires)  AS expires,\n"
"    worker, lock_key, cron_id, args, notes, result\n"
"  FROM pq_jobs\n"
,

/* ---- 2 ------------------------------------------------------------------
 * In lockstep with PQ_SQLITE_UP step 2. */
"ALTER TABLE pq_jobs ADD COLUMN timeout DOUBLE PRECISION\n"
,

/* ---- 3 ------------------------------------------------------------------
 * Per-job log lines: the worker's lifecycle events and whatever the task
 * body writes through $job->log. Rows live and die with their job -
 * remove_job, repair's ancient sweep and reset all cascade here. */
"CREATE TABLE pq_job_logs (\n"
"    id      BIGSERIAL PRIMARY KEY,\n"
"    job_id  BIGINT NOT NULL,\n"
"    created DOUBLE PRECISION NOT NULL,\n"
"    level   TEXT NOT NULL DEFAULT 'info',\n"
"    message TEXT NOT NULL\n"
")\n"
"-- @@\n"
"CREATE INDEX pq_job_logs_job ON pq_job_logs (job_id, id)\n"
,

    NULL   /* terminator */
};

#endif /* PQ_MIGRATE_PG_H */



( run in 1.301 second using v1.01-cache-2.11-cpan-e7c6538aa59 )