sub tasks and task table added

This commit is contained in:
Jun-te Kim 2025-11-10 17:01:08 +00:00
parent 7a80762b95
commit 6bb04a9a72
7 changed files with 9065 additions and 0 deletions

View file

@ -0,0 +1,23 @@
CREATE TABLE "sub_tasks" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"task_id" uuid NOT NULL,
"job_started" timestamp (6) with time zone,
"job_completed" timestamp (6) with time zone,
"status" text DEFAULT 'In Progress' NOT NULL,
"inputs" text,
"outputs" text,
"cloud_logs_url" text,
"updated_at" timestamp (6) with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "tasks" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"task_source" text NOT NULL,
"job_started" timestamp (6) with time zone,
"job_completed" timestamp (6) with time zone,
"status" text DEFAULT 'In Progress' NOT NULL,
"service" text,
"updated_at" timestamp (6) with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "sub_tasks" ADD CONSTRAINT "sub_tasks_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;

View file

@ -0,0 +1,4 @@
ALTER TABLE "sub_tasks" RENAME TO "sub_task";--> statement-breakpoint
ALTER TABLE "sub_task" DROP CONSTRAINT "sub_tasks_task_id_tasks_id_fk";
--> statement-breakpoint
ALTER TABLE "sub_task" ADD CONSTRAINT "sub_task_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -869,6 +869,20 @@
"when": 1761660543815,
"tag": "0123_cloudy_gambit",
"breakpoints": true
},
{
"idx": 124,
"version": "7",
"when": 1762793610067,
"tag": "0124_mute_alice",
"breakpoints": true
},
{
"idx": 125,
"version": "7",
"when": 1762793952263,
"tag": "0125_steady_thunderbolts",
"breakpoints": true
}
]
}

View file

@ -0,0 +1,25 @@
import { pgTable, uuid, text, timestamp } from "drizzle-orm/pg-core";
import { tasks } from "./tasks";
export const subTasks = pgTable("sub_task", {
id: uuid("id").defaultRandom().primaryKey(),
// foreign key to parent task
taskId: uuid("task_id")
.notNull()
.references(() => tasks.id, { onDelete: "cascade" }),
jobStarted: timestamp("job_started", { precision: 6, withTimezone: true }),
jobCompleted: timestamp("job_completed", { precision: 6, withTimezone: true }),
status: text("status").notNull().default("In Progress"),
inputs: text("inputs"), // could later change to JSONB if desired
outputs: text("outputs"),
cloudLogsURL: text("cloud_logs_url"),
updatedAt: timestamp("updated_at", { precision: 6, withTimezone: true })
.defaultNow()
.$onUpdate(() => new Date())
.notNull(),
});

View file

@ -0,0 +1,19 @@
import { pgTable, uuid, text, timestamp } from "drizzle-orm/pg-core";
export const tasks = pgTable("tasks", {
id: uuid("id").defaultRandom().primaryKey(),
taskSource: text("task_source").notNull(),
jobStarted: timestamp("job_started", { precision: 6, withTimezone: true }),
jobCompleted: timestamp("job_completed", { precision: 6, withTimezone: true }),
status: text("status").notNull().default("In Progress"), // default status
service: text("service"), // e.g. plan, wchg etc
updatedAt: timestamp("updated_at", { precision: 6, withTimezone: true })
.defaultNow()
.$onUpdate(() => new Date())
.notNull(),
});