1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-01-31 02:53:36 +00:00
mipilin/drizzle/0007_silly_freak.sql
roxwize 5abe0b5fad
invite cooooddeesss
Signed-off-by: roxwize <rae@roxwize.xyz>
2024-12-10 22:27:43 -05:00

12 lines
459 B
SQL

CREATE TABLE IF NOT EXISTS "invite_codes" (
"token" varchar(8) PRIMARY KEY NOT NULL,
"user_id" integer,
"granted" timestamp NOT NULL,
"expires" timestamp DEFAULT '1970-01-01 00:00:00.000'
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "invite_codes" ADD CONSTRAINT "invite_codes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;