-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
291 additions
and
111 deletions.
There are no files selected for viewing
76 changes: 0 additions & 76 deletions
76
apps/api/src/prisma/migrations/20231225074847_init/migration.sql
This file was deleted.
Oops, something went wrong.
134 changes: 134 additions & 0 deletions
134
apps/api/src/prisma/migrations/20231226184616_init/migration.sql
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,134 @@ | ||
-- CreateEnum | ||
CREATE TYPE "ProjectRole" AS ENUM ('OWNER', 'MAINTAINER', 'VIEWER'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "ApiKeyRole" AS ENUM ('CREATE_PROJECT', 'READ_PROJECT', 'UPDATE_PROJECT', 'DELETE_PROJECT', 'CREATE_SECRET', 'READ_SECRET', 'UPDATE_SECRET', 'DELETE_SECRET', 'ADD_USER', 'REMOVE_USER', 'UPDATE_USER_ROLE', 'CREATE_API_KEY', 'READ_API_KEY', 'UPDATE_API_KEY', 'DELETE_API_KEY'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"name" TEXT, | ||
"profilePictureUrl" TEXT, | ||
"isActive" BOOLEAN NOT NULL DEFAULT true, | ||
"isOnboardingFinished" BOOLEAN NOT NULL DEFAULT false, | ||
"isAdmin" BOOLEAN NOT NULL DEFAULT false, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Subscription" ( | ||
"id" TEXT NOT NULL, | ||
"plan" TEXT NOT NULL, | ||
"isActive" BOOLEAN NOT NULL DEFAULT true, | ||
"userId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Subscription_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Project" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"description" TEXT, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"publicKey" TEXT NOT NULL, | ||
"privateKey" TEXT, | ||
"lastUpdatedById" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Project_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "ProjectMember" ( | ||
"id" TEXT NOT NULL, | ||
"role" "ProjectRole" NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
"projectId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "ProjectMember_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "ApiKeyScope" ( | ||
"id" TEXT NOT NULL, | ||
"role" "ApiKeyRole" NOT NULL, | ||
"apiKeyId" TEXT NOT NULL, | ||
"projectId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "ApiKeyScope_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Secret" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"value" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"rotateAt" TIMESTAMP(3), | ||
"lastUpdatedById" TEXT NOT NULL, | ||
"projectId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Secret_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "ApiKey" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"value" TEXT NOT NULL, | ||
"expiresAt" TIMESTAMP(3), | ||
"userId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "ApiKey_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Otp" ( | ||
"code" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"expiresAt" TIMESTAMP(3) NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Subscription_userId_key" ON "Subscription"("userId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Otp_code_key" ON "Otp"("code"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Subscription" ADD CONSTRAINT "Subscription_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Project" ADD CONSTRAINT "Project_lastUpdatedById_fkey" FOREIGN KEY ("lastUpdatedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ProjectMember" ADD CONSTRAINT "ProjectMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ProjectMember" ADD CONSTRAINT "ProjectMember_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ApiKeyScope" ADD CONSTRAINT "ApiKeyScope_apiKeyId_fkey" FOREIGN KEY ("apiKeyId") REFERENCES "ApiKey"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ApiKeyScope" ADD CONSTRAINT "ApiKeyScope_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Secret" ADD CONSTRAINT "Secret_lastUpdatedById_fkey" FOREIGN KEY ("lastUpdatedById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Secret" ADD CONSTRAINT "Secret_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ApiKey" ADD CONSTRAINT "ApiKey_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Otp" ADD CONSTRAINT "Otp_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
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
7 changes: 7 additions & 0 deletions
7
apps/api/src/project/dto/create.project/create.project.spec.ts
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 @@ | ||
import { CreateProject } from './create.project'; | ||
|
||
describe('CreateProject', () => { | ||
it('should be defined', () => { | ||
expect(new CreateProject()).toBeDefined(); | ||
}); | ||
}); |
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 @@ | ||
export class CreateProject {} |
7 changes: 7 additions & 0 deletions
7
apps/api/src/project/dto/update.project/update.project.spec.ts
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 @@ | ||
import { UpdateProject } from './update.project'; | ||
|
||
describe('UpdateProject', () => { | ||
it('should be defined', () => { | ||
expect(new UpdateProject()).toBeDefined(); | ||
}); | ||
}); |
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 @@ | ||
export class UpdateProject {} |
Oops, something went wrong.