1+ CREATE SCHEMA IF NOT EXISTS " duron" ;
2+ -- > statement-breakpoint
3+ CREATE TABLE "duron "." job_steps" (
4+ " id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
5+ " job_id" uuid NOT NULL ,
6+ " name" text NOT NULL ,
7+ " status" text DEFAULT ' active' NOT NULL ,
8+ " output" jsonb,
9+ " error" jsonb,
10+ " started_at" timestamp with time zone DEFAULT now() NOT NULL ,
11+ " finished_at" timestamp with time zone ,
12+ " timeout_ms" integer NOT NULL ,
13+ " expires_at" timestamp with time zone ,
14+ " retries_limit" integer DEFAULT 0 NOT NULL ,
15+ " retries_count" integer DEFAULT 0 NOT NULL ,
16+ " delayed_ms" integer ,
17+ " history_failed_attempts" jsonb DEFAULT ' {}' NOT NULL ,
18+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
19+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
20+ CONSTRAINT " unique_job_step_name" UNIQUE(" job_id" ," name" ),
21+ CONSTRAINT " job_steps_status_check" CHECK (" status" IN (' active' ,' completed' ,' failed' ,' cancelled' ))
22+ );
23+ -- > statement-breakpoint
24+ CREATE TABLE "duron "." jobs" (
25+ " id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
26+ " action_name" text NOT NULL ,
27+ " group_key" text NOT NULL ,
28+ " status" text DEFAULT ' created' NOT NULL ,
29+ " checksum" text NOT NULL ,
30+ " input" jsonb DEFAULT ' {}' NOT NULL ,
31+ " output" jsonb,
32+ " error" jsonb,
33+ " timeout_ms" integer NOT NULL ,
34+ " expires_at" timestamp with time zone ,
35+ " started_at" timestamp with time zone ,
36+ " finished_at" timestamp with time zone ,
37+ " owner_id" text ,
38+ " concurrency_limit" integer DEFAULT 10 NOT NULL ,
39+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
40+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
41+ CONSTRAINT " jobs_status_check" CHECK (" status" IN (' created' ,' active' ,' completed' ,' failed' ,' cancelled' ))
42+ );
43+ -- > statement-breakpoint
44+ CREATE INDEX "idx_job_steps_job_id " ON " duron" ." job_steps" (" job_id" );-- > statement-breakpoint
45+ CREATE INDEX "idx_job_steps_status " ON " duron" ." job_steps" (" status" );-- > statement-breakpoint
46+ CREATE INDEX "idx_job_steps_name " ON " duron" ." job_steps" (" name" );-- > statement-breakpoint
47+ CREATE INDEX "idx_job_steps_expires_at " ON " duron" ." job_steps" (" expires_at" );-- > statement-breakpoint
48+ CREATE INDEX "idx_job_steps_job_status " ON " duron" ." job_steps" (" job_id" ," status" );-- > statement-breakpoint
49+ CREATE INDEX "idx_job_steps_job_name " ON " duron" ." job_steps" (" job_id" ," name" );-- > statement-breakpoint
50+ CREATE INDEX "idx_job_steps_output_fts " ON " duron" ." job_steps" USING gin (to_tsvector(' english' , " output" ::text ));-- > statement-breakpoint
51+ CREATE INDEX "idx_jobs_action_name " ON " duron" ." jobs" (" action_name" );-- > statement-breakpoint
52+ CREATE INDEX "idx_jobs_status " ON " duron" ." jobs" (" status" );-- > statement-breakpoint
53+ CREATE INDEX "idx_jobs_group_key " ON " duron" ." jobs" (" group_key" );-- > statement-breakpoint
54+ CREATE INDEX "idx_jobs_started_at " ON " duron" ." jobs" (" started_at" );-- > statement-breakpoint
55+ CREATE INDEX "idx_jobs_finished_at " ON " duron" ." jobs" (" finished_at" );-- > statement-breakpoint
56+ CREATE INDEX "idx_jobs_expires_at " ON " duron" ." jobs" (" expires_at" );-- > statement-breakpoint
57+ CREATE INDEX "idx_jobs_owner_id " ON " duron" ." jobs" (" owner_id" );-- > statement-breakpoint
58+ CREATE INDEX "idx_jobs_checksum " ON " duron" ." jobs" (" checksum" );-- > statement-breakpoint
59+ CREATE INDEX "idx_jobs_concurrency_limit " ON " duron" ." jobs" (" concurrency_limit" );-- > statement-breakpoint
60+ CREATE INDEX "idx_jobs_action_status " ON " duron" ." jobs" (" action_name" ," status" );-- > statement-breakpoint
61+ CREATE INDEX "idx_jobs_action_group " ON " duron" ." jobs" (" action_name" ," group_key" );-- > statement-breakpoint
62+ CREATE INDEX "idx_jobs_input_fts " ON " duron" ." jobs" USING gin (to_tsvector(' english' , " input" ::text ));-- > statement-breakpoint
63+ CREATE INDEX "idx_jobs_output_fts " ON " duron" ." jobs" USING gin (to_tsvector(' english' , " output" ::text ));-- > statement-breakpoint
64+ ALTER TABLE " duron" ." job_steps" ADD CONSTRAINT " job_steps_job_id_jobs_id_fkey" FOREIGN KEY (" job_id" ) REFERENCES " duron" ." jobs" (" id" ) ON DELETE CASCADE ;
0 commit comments