20 lines
943 B
SQL
20 lines
943 B
SQL
CREATE TABLE IF NOT EXISTS "resource_links" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"user_id" uuid NOT NULL,
|
|
"date" date NOT NULL,
|
|
"week_start" date NOT NULL,
|
|
"title" varchar(300) NOT NULL,
|
|
"url" text NOT NULL,
|
|
"category" varchar(120) DEFAULT 'Interesting things to read up:' NOT NULL,
|
|
"notes" text,
|
|
"status" varchar(20) DEFAULT 'inbox' NOT NULL,
|
|
"exported_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "resource_links" ADD CONSTRAINT "resource_links_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
--> statement-breakpoint
|
|
CREATE INDEX IF NOT EXISTS "resource_links_user_week_idx" ON "resource_links" ("user_id", "week_start");
|
|
--> statement-breakpoint
|
|
CREATE INDEX IF NOT EXISTS "resource_links_user_status_idx" ON "resource_links" ("user_id", "status");
|