forked from koshikraj/ottopus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0009_plans_grant_review_tokens.sql
More file actions
17 lines (17 loc) · 1.16 KB
/
Copy path0009_plans_grant_review_tokens.sql
File metadata and controls
17 lines (17 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
CREATE TABLE "review_tokens" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"token_hash" text NOT NULL,
"plan_id" uuid NOT NULL,
"plan_version" integer NOT NULL,
"expires_at" timestamp with time zone NOT NULL,
"revoked_at" timestamp with time zone,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "review_tokens_token_hash_unique" UNIQUE("token_hash")
);
--> statement-breakpoint
ALTER TABLE "plan_events" ADD COLUMN "seq" bigserial NOT NULL;--> statement-breakpoint
ALTER TABLE "plans" ADD COLUMN "grant_id" uuid;--> statement-breakpoint
ALTER TABLE "review_tokens" ADD CONSTRAINT "review_tokens_plan_fk" FOREIGN KEY ("plan_id","plan_version") REFERENCES "public"."plans"("id","version") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "review_tokens_plan_idx" ON "review_tokens" USING btree ("plan_id","plan_version");--> statement-breakpoint
ALTER TABLE "plans" ADD CONSTRAINT "plans_grant_id_oauth_grants_id_fk" FOREIGN KEY ("grant_id") REFERENCES "public"."oauth_grants"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "plans_grant_idx" ON "plans" USING btree ("grant_id");