mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 19:24:03 +00:00
feat(WHE-27): add drizzle db package and typed env config
This commit is contained in:
18
packages/db/drizzle/0000_modern_centennial.sql
Normal file
18
packages/db/drizzle/0000_modern_centennial.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE "households" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "members" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"household_id" uuid NOT NULL,
|
||||
"telegram_user_id" text NOT NULL,
|
||||
"display_name" text NOT NULL,
|
||||
"is_admin" integer DEFAULT 0 NOT NULL,
|
||||
"joined_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "members" ADD CONSTRAINT "members_household_id_households_id_fk" FOREIGN KEY ("household_id") REFERENCES "public"."households"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "members_household_idx" ON "members" USING btree ("household_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "members_household_tg_user_unique" ON "members" USING btree ("household_id","telegram_user_id");
|
||||
Reference in New Issue
Block a user