-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(user): add user api keys schema + api
(#787)
- Loading branch information
Showing
31 changed files
with
1,878 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CREATE TABLE IF NOT EXISTS "api_keys" ( | ||
"id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL, | ||
"user_id" uuid NOT NULL, | ||
"hashed_key" varchar NOT NULL, | ||
"key_format" varchar NOT NULL, | ||
"name" varchar NOT NULL, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp DEFAULT now() NOT NULL, | ||
"expires_at" timestamp, | ||
CONSTRAINT "api_keys_hashed_key_unique" UNIQUE("hashed_key"), | ||
CONSTRAINT "api_keys_key_format_unique" UNIQUE("key_format") | ||
); | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "api_keys" ADD CONSTRAINT "api_keys_user_id_userSetting_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."userSetting"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
Oops, something went wrong.