14 lines
842 B
SQL
14 lines
842 B
SQL
CREATE TABLE "invites" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"code" text NOT NULL,
|
|
"role" text DEFAULT 'viewer' NOT NULL,
|
|
"created_by_user_id" text,
|
|
"expires_at" timestamp with time zone NOT NULL,
|
|
"used_by_user_id" text,
|
|
"used_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "invites" ADD CONSTRAINT "invites_created_by_user_id_users_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "invites" ADD CONSTRAINT "invites_used_by_user_id_users_id_fk" FOREIGN KEY ("used_by_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "invites_code_unique" ON "invites" USING btree ("code"); |