@spfn/auth 0.3.0-beta.17 → 0.3.0-beta.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ CREATE TABLE "spfn_auth"."oauth2_clients" (
2
+ "id" bigserial PRIMARY KEY,
3
+ "client_id" text NOT NULL UNIQUE,
4
+ "client_name" text NOT NULL,
5
+ "redirect_uris" text[] NOT NULL,
6
+ "created_ip" text,
7
+ "last_used_at" timestamp with time zone,
8
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
9
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE TABLE "spfn_auth"."oauth2_grants" (
13
+ "id" bigserial PRIMARY KEY,
14
+ "oauth2_client_id" bigint NOT NULL,
15
+ "user_id" bigint NOT NULL,
16
+ "resource" text NOT NULL,
17
+ "scopes" text[] NOT NULL,
18
+ "revoked_at" timestamp with time zone,
19
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
20
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE TABLE "spfn_auth"."oauth2_authorization_codes" (
24
+ "id" bigserial PRIMARY KEY,
25
+ "code_hash" text NOT NULL UNIQUE,
26
+ "oauth2_grant_id" bigint NOT NULL,
27
+ "redirect_uri" text NOT NULL,
28
+ "code_challenge" text NOT NULL,
29
+ "expires_at" timestamp with time zone NOT NULL,
30
+ "used_at" timestamp with time zone,
31
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
32
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
33
+ );
34
+ --> statement-breakpoint
35
+ CREATE TABLE "spfn_auth"."oauth2_tokens" (
36
+ "id" bigserial PRIMARY KEY,
37
+ "token_hash" text NOT NULL UNIQUE,
38
+ "kind" text NOT NULL,
39
+ "oauth2_grant_id" bigint NOT NULL,
40
+ "scopes" text[] NOT NULL,
41
+ "expires_at" timestamp with time zone NOT NULL,
42
+ "revoked_at" timestamp with time zone,
43
+ "replaced_at" timestamp with time zone,
44
+ "last_used_at" timestamp with time zone,
45
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
46
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
47
+ );
48
+ --> statement-breakpoint
49
+ CREATE UNIQUE INDEX "oauth2_grant_client_user_resource_idx" ON "spfn_auth"."oauth2_grants" ("oauth2_client_id","user_id","resource");--> statement-breakpoint
50
+ CREATE INDEX "oauth2_grant_user_idx" ON "spfn_auth"."oauth2_grants" ("user_id");--> statement-breakpoint
51
+ CREATE INDEX "oauth2_token_grant_idx" ON "spfn_auth"."oauth2_tokens" ("oauth2_grant_id");--> statement-breakpoint
52
+ ALTER TABLE "spfn_auth"."oauth2_grants" ADD CONSTRAINT "oauth2_grants_oauth2_client_id_oauth2_clients_id_fkey" FOREIGN KEY ("oauth2_client_id") REFERENCES "spfn_auth"."oauth2_clients"("id") ON DELETE CASCADE;--> statement-breakpoint
53
+ ALTER TABLE "spfn_auth"."oauth2_grants" ADD CONSTRAINT "oauth2_grants_user_id_users_id_fkey" FOREIGN KEY ("user_id") REFERENCES "spfn_auth"."users"("id") ON DELETE CASCADE;--> statement-breakpoint
54
+ ALTER TABLE "spfn_auth"."oauth2_authorization_codes" ADD CONSTRAINT "oauth2_authorization_codes_vL0GWtxW3xnt_fkey" FOREIGN KEY ("oauth2_grant_id") REFERENCES "spfn_auth"."oauth2_grants"("id") ON DELETE CASCADE;--> statement-breakpoint
55
+ ALTER TABLE "spfn_auth"."oauth2_tokens" ADD CONSTRAINT "oauth2_tokens_oauth2_grant_id_oauth2_grants_id_fkey" FOREIGN KEY ("oauth2_grant_id") REFERENCES "spfn_auth"."oauth2_grants"("id") ON DELETE CASCADE;