-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from kumpmati/feature/basic-api
Basic API #minor
- Loading branch information
Showing
41 changed files
with
2,686 additions
and
216 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE TABLE IF NOT EXISTS "api_key" ( | ||
"id" varchar(15), | ||
"secret" text, | ||
"user_id" varchar(15) NOT NULL, | ||
"timestamp" timestamp DEFAULT now() NOT NULL, | ||
CONSTRAINT "api_key_id_secret_pk" PRIMARY KEY("id","secret") | ||
); | ||
--> statement-breakpoint | ||
CREATE INDEX IF NOT EXISTS "api_key_user_id_idx" ON "api_key" ("user_id");--> statement-breakpoint | ||
CREATE INDEX IF NOT EXISTS "api_key_created_at_idx" ON "api_key" ("timestamp");--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "api_key" ADD CONSTRAINT "api_key_user_id_auth_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth_user"("id") ON DELETE cascade ON UPDATE cascade; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
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,7 @@ | ||
ALTER TABLE "link_visit" ALTER COLUMN "timestamp" SET DATA TYPE timestamp with time zone;--> statement-breakpoint | ||
ALTER TABLE "api_key" ALTER COLUMN "timestamp" SET DATA TYPE timestamp with time zone;--> statement-breakpoint | ||
ALTER TABLE "signup_token" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint | ||
ALTER TABLE "signup_token" ALTER COLUMN "used_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint | ||
ALTER TABLE "links" ALTER COLUMN "created_at" SET DATA TYPE timestamp with time zone;--> statement-breakpoint | ||
ALTER TABLE "links" ALTER COLUMN "last_used" SET DATA TYPE timestamp with time zone;--> statement-breakpoint | ||
ALTER TABLE "links" ALTER COLUMN "valid_until" SET DATA TYPE timestamp with time zone; |
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,2 @@ | ||
ALTER TABLE "api_key" ALTER COLUMN "id" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "api_key" ALTER COLUMN "secret" SET NOT NULL; |
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,3 @@ | ||
ALTER TABLE "api_key" RENAME COLUMN "timestamp" TO "created_at";--> statement-breakpoint | ||
DROP INDEX IF EXISTS "api_key_created_at_idx";--> statement-breakpoint | ||
CREATE INDEX IF NOT EXISTS "api_key_created_at_idx" ON "api_key" ("created_at"); |
Oops, something went wrong.