mirror of
https://git.sr.ht/~roxwize/mipilin
synced 2025-01-31 02:53:36 +00:00
13 lines
459 B
MySQL
13 lines
459 B
MySQL
|
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 $$;
|