30 lines
1.3 KiB
SQL
30 lines
1.3 KiB
SQL
CREATE TABLE "app_settings" (
|
|
"key" text PRIMARY KEY NOT NULL,
|
|
"value" text NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "training_lessons" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"title" text NOT NULL,
|
|
"summary" text,
|
|
"body" text DEFAULT '' NOT NULL,
|
|
"published" boolean DEFAULT false NOT NULL,
|
|
"sort_order" integer DEFAULT 0 NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "training_resources" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"lesson_id" text NOT NULL,
|
|
"filename" text NOT NULL,
|
|
"mime_type" text NOT NULL,
|
|
"size_bytes" integer NOT NULL,
|
|
"stored_name" text NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "training_resources" ADD CONSTRAINT "training_resources_lesson_id_training_lessons_id_fk" FOREIGN KEY ("lesson_id") REFERENCES "public"."training_lessons"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "training_lessons_published_idx" ON "training_lessons" USING btree ("published");--> statement-breakpoint
|
|
CREATE INDEX "training_resources_lesson_idx" ON "training_resources" USING btree ("lesson_id"); |