63 lines
3.4 KiB
SQL
Executable File
63 lines
3.4 KiB
SQL
Executable File
CREATE TABLE IF NOT EXISTS "daily_todos" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"daily_adventure_id" uuid NOT NULL,
|
|
"label" varchar(300) NOT NULL,
|
|
"done" boolean DEFAULT false NOT NULL,
|
|
"sort_order" integer DEFAULT 0 NOT NULL,
|
|
"deleted_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "daily_todos" ADD CONSTRAINT "daily_todos_daily_adventure_id_daily_adventures_id_fk" FOREIGN KEY ("daily_adventure_id") REFERENCES "public"."daily_adventures"("id") ON DELETE cascade ON UPDATE no action;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "daily_adventures" ADD COLUMN IF NOT EXISTS "work_hours_target" numeric(4, 1);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "daily_adventures" ADD COLUMN IF NOT EXISTS "is_customized" boolean DEFAULT false NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "daily_adventures" ADD COLUMN IF NOT EXISTS "customized_at" timestamp with time zone;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "daily_adventure_items" ADD COLUMN IF NOT EXISTS "is_custom" boolean DEFAULT false NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "daily_adventure_items" ADD COLUMN IF NOT EXISTS "enabled" boolean DEFAULT true NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "daily_adventure_items" ADD COLUMN IF NOT EXISTS "deleted_at" timestamp with time zone;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "adventure_templates" ADD COLUMN IF NOT EXISTS "sort_priority" integer DEFAULT 0 NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "adventure_templates" ADD COLUMN IF NOT EXISTS "deleted_at" timestamp with time zone;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "adventure_templates" ADD COLUMN IF NOT EXISTS "is_system" boolean DEFAULT false NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "adventure_items" ADD COLUMN IF NOT EXISTS "enabled" boolean DEFAULT true NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "adventure_items" ADD COLUMN IF NOT EXISTS "item_kind" varchar(20) DEFAULT 'recurring' NOT NULL;
|
|
--> statement-breakpoint
|
|
CREATE TABLE IF NOT EXISTS "reading_progress" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"user_id" uuid NOT NULL,
|
|
"calibre_book_id" integer NOT NULL,
|
|
"calibre_uuid" varchar(36),
|
|
"current_page" integer DEFAULT 0 NOT NULL,
|
|
"total_pages" integer DEFAULT 300 NOT NULL,
|
|
"status" varchar(20) DEFAULT 'reading' NOT NULL,
|
|
"last_read_date" date,
|
|
"notes" text,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "reading_progress" ADD CONSTRAINT "reading_progress_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "reading_progress_user_calibre_idx" ON "reading_progress" ("user_id", "calibre_book_id");
|
|
--> statement-breakpoint
|
|
ALTER TABLE "reading_logs" ADD COLUMN IF NOT EXISTS "calibre_book_id" integer;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "reading_logs" ALTER COLUMN "book_id" DROP NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "teacher_content" ADD COLUMN IF NOT EXISTS "status" varchar(20) DEFAULT 'active' NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "teacher_content" ADD COLUMN IF NOT EXISTS "completed_note" text;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "teacher_content" ADD COLUMN IF NOT EXISTS "completed_at" timestamp with time zone;
|
|
--> statement-breakpoint
|
|
ALTER TABLE "explorations" ADD COLUMN IF NOT EXISTS "minutes" integer;
|