Add notes module
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
CREATE TABLE "reminders" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"household_id" uuid NOT NULL,
|
||||
"entity_type" text NOT NULL,
|
||||
"entity_id" uuid NOT NULL,
|
||||
"fire_at" timestamp with time zone NOT NULL,
|
||||
"channel" text DEFAULT 'in_app' NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "notes" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"household_id" uuid NOT NULL,
|
||||
"author_id" uuid NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"body" text DEFAULT '' NOT NULL,
|
||||
"pinned" boolean DEFAULT false NOT NULL,
|
||||
"remind_at" timestamp with time zone,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "reminders" ADD CONSTRAINT "reminders_household_id_households_id_fk" FOREIGN KEY ("household_id") REFERENCES "public"."households"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "notes" ADD CONSTRAINT "notes_household_id_households_id_fk" FOREIGN KEY ("household_id") REFERENCES "public"."households"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "notes" ADD CONSTRAINT "notes_author_id_users_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "reminders_entity_unique" ON "reminders" USING btree ("entity_type","entity_id");--> statement-breakpoint
|
||||
CREATE INDEX "reminders_household_fire_at_idx" ON "reminders" USING btree ("household_id","fire_at");--> statement-breakpoint
|
||||
CREATE INDEX "notes_household_pinned_updated_idx" ON "notes" USING btree ("household_id","pinned","updated_at");--> statement-breakpoint
|
||||
CREATE INDEX "notes_author_idx" ON "notes" USING btree ("author_id");
|
||||
Reference in New Issue
Block a user