Punk-Queue
view release on metacpan or search on metacpan
include/pq_migrate_sqlite.h view on Meta::CPAN
" task TEXT NOT NULL,\n"
" args TEXT NOT NULL DEFAULT '[]',\n"
" queue TEXT NOT NULL DEFAULT 'default',\n"
" priority INTEGER NOT NULL DEFAULT 0,\n"
" 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 REAL,\n"
" next_run REAL NOT NULL,\n"
" last_job INTEGER,\n"
" created REAL NOT NULL,\n"
" updated REAL NOT NULL\n"
")\n"
"-- @@\n"
/* THE index. Partial on state, so the b-tree only ever holds claimable
* rows and stays small however large the finished history grows.
* `delayed` and `parents_left` are deliberately absent: putting `delayed`
* ahead of `priority` kills the ordered scan, and putting it after does
* nothing. They filter an already-tiny index. */
"CREATE INDEX pq_jobs_ready ON pq_jobs (queue, priority DESC, id)\n"
" WHERE state = 'inactive'\n"
"-- @@\n"
/* arms the idle sleep horizon: SELECT min(delayed) ... */
"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"
/* unique-job dedupe: only live jobs collide, so a finished job does not
* block a re-enqueue of the same key */
"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"
/* the leader-election arbiter: one INSERT wins, the rest get a constraint
* violation, which removes the count-then-insert race for limit-1 leases */
"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"
,
/* ---- 2 ------------------------------------------------------------------
* Per-job timeout, seconds; NULL means none. A new column rather than a
* notes key because the supervisor's hard-kill check reads it on every
* claim line and phase 8's UI filters on it. */
"ALTER TABLE pq_jobs ADD COLUMN timeout REAL\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 INTEGER PRIMARY KEY AUTOINCREMENT,\n"
" job_id INTEGER NOT NULL,\n"
" created REAL 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_SQLITE_H */
( run in 0.783 second using v1.01-cache-2.11-cpan-e7c6538aa59 )