Production readiness hardening and ops tooling
This commit is contained in:
5
migrations/001_current_schema_bootstrap.mts
Normal file
5
migrations/001_current_schema_bootstrap.mts
Normal file
@ -0,0 +1,5 @@
|
||||
import type { ensureSchema } from "../src/shared/db/pool";
|
||||
|
||||
export async function up(context: { ensureSchema: typeof ensureSchema }) {
|
||||
await context.ensureSchema();
|
||||
}
|
||||
16
migrations/002_export_jobs.sql
Normal file
16
migrations/002_export_jobs.sql
Normal file
@ -0,0 +1,16 @@
|
||||
CREATE TABLE IF NOT EXISTS export_jobs (
|
||||
id TEXT PRIMARY KEY,
|
||||
job_type TEXT NOT NULL,
|
||||
status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'running', 'completed', 'failed')),
|
||||
requested_by TEXT,
|
||||
request_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
result_content_type TEXT,
|
||||
result_filename TEXT,
|
||||
result_body TEXT,
|
||||
error_message TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL,
|
||||
started_at TIMESTAMPTZ,
|
||||
completed_at TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_export_jobs_status ON export_jobs (status, created_at DESC);
|
||||
6
migrations/003_export_job_storage.sql
Normal file
6
migrations/003_export_job_storage.sql
Normal file
@ -0,0 +1,6 @@
|
||||
ALTER TABLE export_jobs
|
||||
ADD COLUMN IF NOT EXISTS result_storage_path TEXT,
|
||||
ADD COLUMN IF NOT EXISTS result_size_bytes INTEGER,
|
||||
ADD COLUMN IF NOT EXISTS expires_at TIMESTAMPTZ;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_export_jobs_expires_at ON export_jobs (expires_at);
|
||||
Reference in New Issue
Block a user