Private
Public Access
1
0
Files
linux_patch_manager/migrations/003_jobs_scheduling.sql
git-echo 124b5b0e3b feat: add bump-version.sh script for version management
Automates version bumps across all version source files:
- Cargo.toml (PRIMARY - workspace.package.version)
- debian/changelog (prepend new entry)
- debian/control (update Version field)
- scripts/build-package.sh (update VERSION variable)
- frontend/package.json (update version field)
- Stale references check after bump

Usage: ./scripts/bump-version.sh <new_version> <old_version>
2026-05-28 10:52:16 -05:00

45 lines
1.4 KiB
PL/PgSQL

-- Migration: 003_jobs_scheduling
-- Description: Retry/scheduling columns for patch_job_hosts, and NOTIFY trigger
-- for immediate patch job dispatch.
-- ============================================================
-- Add retry-scheduling columns to patch_job_hosts
-- ============================================================
-- When the retry engine should next attempt this host; NULL = not scheduled
ALTER TABLE patch_job_hosts
ADD COLUMN retry_next_at TIMESTAMPTZ;
-- Last failure reason captured by the worker for display in the UI
ALTER TABLE patch_job_hosts
ADD COLUMN last_error TEXT;
-- ============================================================
-- pg_notify trigger: fires when an immediate job is inserted
-- ============================================================
CREATE OR REPLACE FUNCTION notify_job_enqueued()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
BEGIN
IF NEW.immediate = TRUE THEN
PERFORM pg_notify('job_enqueued', NEW.id::text);
END IF;
RETURN NEW;
END;
$$;
CREATE TRIGGER trg_job_enqueued
AFTER INSERT ON patch_jobs
FOR EACH ROW
EXECUTE FUNCTION notify_job_enqueued();
-- ============================================================
-- Index: efficiently find hosts due for retry
-- ============================================================
CREATE INDEX idx_pjh_retry
ON patch_job_hosts (retry_next_at)
WHERE retry_next_at IS NOT NULL;