From e8067ae73dd0888330c57056f1790a9953f60491 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Wed, 13 Apr 2022 02:24:54 +0200 Subject: [PATCH] feat: migration for api keys schema --- .../migration.sql | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/prisma/migrations/20220413002425_adds_api_keys/migration.sql diff --git a/packages/prisma/migrations/20220413002425_adds_api_keys/migration.sql b/packages/prisma/migrations/20220413002425_adds_api_keys/migration.sql new file mode 100644 index 0000000000..58cb57c7e6 --- /dev/null +++ b/packages/prisma/migrations/20220413002425_adds_api_keys/migration.sql @@ -0,0 +1,27 @@ +-- CreateTable +CREATE TABLE "ApiKey" ( + "id" TEXT NOT NULL, + "userId" INTEGER NOT NULL, + "note" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "expiresAt" TIMESTAMP(3), + "lastUsedAt" TIMESTAMP(3), + "hashedKey" TEXT NOT NULL, + + CONSTRAINT "ApiKey_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "ApiKey_id_key" ON "ApiKey"("id"); + +-- CreateIndex +CREATE UNIQUE INDEX "ApiKey_hashedKey_key" ON "ApiKey"("hashedKey"); + +-- AddForeignKey +ALTER TABLE "ApiKey" ADD CONSTRAINT "ApiKey_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- RenameIndex +ALTER INDEX "VerificationRequest.identifier_token_unique" RENAME TO "VerificationRequest_identifier_token_key"; + +-- RenameIndex +ALTER INDEX "VerificationRequest.token_unique" RENAME TO "VerificationRequest_token_key";