908c37f73f
Module manages PostgreSQL (both databases + schema init), qBittorrent (VPN-confined via VPN-Confinement), Jackett, metadata-agregator, musicfs, and the main orchestrator. All services are independently enableable with auto-wired inter-service configuration. Includes NixOS VM test validating PostgreSQL setup, schema initialization, service startup, and directory creation. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/claude-agent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
34 lines
1.4 KiB
SQL
34 lines
1.4 KiB
SQL
CREATE TABLE workflow_runs (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
album_id UUID NOT NULL REFERENCES albums(id) ON DELETE CASCADE,
|
|
quality VARCHAR(20) NOT NULL,
|
|
status VARCHAR(20) NOT NULL DEFAULT 'running',
|
|
error_message TEXT,
|
|
started_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
completed_at TIMESTAMPTZ,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
running_lock BOOLEAN GENERATED ALWAYS AS (CASE WHEN status = 'running' THEN TRUE ELSE NULL END) STORED,
|
|
CONSTRAINT idx_workflow_runs_active UNIQUE (album_id, quality, running_lock)
|
|
);
|
|
|
|
CREATE INDEX idx_workflow_runs_status ON workflow_runs(status);
|
|
|
|
CREATE TABLE album_events (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
seq BIGSERIAL NOT NULL,
|
|
workflow_run_id UUID NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,
|
|
album_id UUID NOT NULL,
|
|
event_type VARCHAR(20) NOT NULL,
|
|
step VARCHAR(50) NOT NULL,
|
|
message TEXT NOT NULL,
|
|
data_json JSONB,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_album_events_workflow ON album_events(workflow_run_id);
|
|
CREATE INDEX idx_album_events_album ON album_events(album_id);
|
|
CREATE INDEX idx_album_events_seq ON album_events(seq);
|
|
|
|
ALTER TYPE download_state ADD VALUE IF NOT EXISTS 'cancelled';
|