diff --git a/apps/server-nestjs/src/prisma/migrations/20260728095729_add_deployment_value_sources/migration.sql b/apps/server-nestjs/src/prisma/migrations/20260728095729_add_deployment_value_sources/migration.sql new file mode 100644 index 0000000000..0d3edfec93 --- /dev/null +++ b/apps/server-nestjs/src/prisma/migrations/20260728095729_add_deployment_value_sources/migration.sql @@ -0,0 +1,44 @@ +-- CreateTable +CREATE TABLE "DeploymentInternalValueSource" ( + "id" UUID NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "deploymentSourceId" UUID NOT NULL, + "order" INTEGER NOT NULL, + "path" TEXT NOT NULL DEFAULT '', + + CONSTRAINT "DeploymentInternalValueSource_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "DeploymentExternalValueSource" ( + "id" UUID NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "deploymentSourceId" UUID NOT NULL, + "order" INTEGER NOT NULL, + "path" TEXT NOT NULL DEFAULT '', + "ref" TEXT NOT NULL, + "targetRevision" TEXT NOT NULL DEFAULT '', + "repositoryId" UUID NOT NULL, + + CONSTRAINT "DeploymentExternalValueSource_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "DeploymentInternalValueSource_id_key" ON "DeploymentInternalValueSource"("id"); + +-- CreateIndex +CREATE UNIQUE INDEX "DeploymentExternalValueSource_id_key" ON "DeploymentExternalValueSource"("id"); + +-- CreateIndex +CREATE UNIQUE INDEX "DeploymentExternalValueSource_deploymentSourceId_key" ON "DeploymentExternalValueSource"("deploymentSourceId"); + +-- AddForeignKey +ALTER TABLE "DeploymentInternalValueSource" ADD CONSTRAINT "DeploymentInternalValueSource_deploymentSourceId_fkey" FOREIGN KEY ("deploymentSourceId") REFERENCES "DeploymentSource"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "DeploymentExternalValueSource" ADD CONSTRAINT "DeploymentExternalValueSource_deploymentSourceId_fkey" FOREIGN KEY ("deploymentSourceId") REFERENCES "DeploymentSource"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "DeploymentExternalValueSource" ADD CONSTRAINT "DeploymentExternalValueSource_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/apps/server-nestjs/src/prisma/schema/project.prisma b/apps/server-nestjs/src/prisma/schema/project.prisma index 6bcc5ce949..94d33c7894 100644 --- a/apps/server-nestjs/src/prisma/schema/project.prisma +++ b/apps/server-nestjs/src/prisma/schema/project.prisma @@ -12,17 +12,43 @@ model Deployment { } model DeploymentSource { - id String @id @unique @default(uuid()) @db.Uuid - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - deploymentId String @db.Uuid - repositoryId String @db.Uuid - type DeploymentSourceType - targetRevision String @default("") - path String @default("") - helmValuesFiles String @default("") - repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade) - deployment Deployment @relation(fields: [deploymentId], references: [id], onDelete: Cascade) + id String @id @unique @default(uuid()) @db.Uuid + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + deploymentId String @db.Uuid + repositoryId String @db.Uuid + type DeploymentSourceType + targetRevision String @default("") + path String @default("") + helmValuesFiles String @default("") + repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade) + deployment Deployment @relation(fields: [deploymentId], references: [id], onDelete: Cascade) + internalValueSources DeploymentInternalValueSource[] + externalValueSource DeploymentExternalValueSource? +} + +model DeploymentInternalValueSource { + id String @id @unique @default(uuid()) @db.Uuid + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + deploymentSourceId String @db.Uuid + order Int + path String @default("") + deploymentSource DeploymentSource @relation(fields: [deploymentSourceId], references: [id], onDelete: Cascade) +} + +model DeploymentExternalValueSource { + id String @id @unique @default(uuid()) @db.Uuid + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + deploymentSourceId String @unique @db.Uuid + order Int + path String @default("") + ref String + targetRevision String @default("") + repositoryId String @db.Uuid + deploymentSource DeploymentSource @relation(fields: [deploymentSourceId], references: [id], onDelete: Cascade) + repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade) } model Environment { @@ -46,20 +72,21 @@ model Environment { } model Repository { - id String @id @default(uuid()) @db.Uuid - projectId String @db.Uuid - internalRepoName String - externalRepoUrl String @default("") - externalUserName String @default("") - isInfra Boolean @default(false) - isPrivate Boolean @default(false) - deployRevision String @default("") - deployPath String @default("") - helmValuesFiles String @default("") - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - project Project @relation(fields: [projectId], references: [id], onDelete: Cascade) - deploymentSources DeploymentSource[] + id String @id @default(uuid()) @db.Uuid + projectId String @db.Uuid + internalRepoName String + externalRepoUrl String @default("") + externalUserName String @default("") + isInfra Boolean @default(false) + isPrivate Boolean @default(false) + deployRevision String @default("") + deployPath String @default("") + helmValuesFiles String @default("") + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + project Project @relation(fields: [projectId], references: [id], onDelete: Cascade) + deploymentSources DeploymentSource[] + deploymentExternalValueSources DeploymentExternalValueSource[] } model ProjectClusterHistory { diff --git a/apps/server/src/prisma/migrations/20260728095729_add_deployment_value_sources/migration.sql b/apps/server/src/prisma/migrations/20260728095729_add_deployment_value_sources/migration.sql new file mode 100644 index 0000000000..0d3edfec93 --- /dev/null +++ b/apps/server/src/prisma/migrations/20260728095729_add_deployment_value_sources/migration.sql @@ -0,0 +1,44 @@ +-- CreateTable +CREATE TABLE "DeploymentInternalValueSource" ( + "id" UUID NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "deploymentSourceId" UUID NOT NULL, + "order" INTEGER NOT NULL, + "path" TEXT NOT NULL DEFAULT '', + + CONSTRAINT "DeploymentInternalValueSource_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "DeploymentExternalValueSource" ( + "id" UUID NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "deploymentSourceId" UUID NOT NULL, + "order" INTEGER NOT NULL, + "path" TEXT NOT NULL DEFAULT '', + "ref" TEXT NOT NULL, + "targetRevision" TEXT NOT NULL DEFAULT '', + "repositoryId" UUID NOT NULL, + + CONSTRAINT "DeploymentExternalValueSource_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "DeploymentInternalValueSource_id_key" ON "DeploymentInternalValueSource"("id"); + +-- CreateIndex +CREATE UNIQUE INDEX "DeploymentExternalValueSource_id_key" ON "DeploymentExternalValueSource"("id"); + +-- CreateIndex +CREATE UNIQUE INDEX "DeploymentExternalValueSource_deploymentSourceId_key" ON "DeploymentExternalValueSource"("deploymentSourceId"); + +-- AddForeignKey +ALTER TABLE "DeploymentInternalValueSource" ADD CONSTRAINT "DeploymentInternalValueSource_deploymentSourceId_fkey" FOREIGN KEY ("deploymentSourceId") REFERENCES "DeploymentSource"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "DeploymentExternalValueSource" ADD CONSTRAINT "DeploymentExternalValueSource_deploymentSourceId_fkey" FOREIGN KEY ("deploymentSourceId") REFERENCES "DeploymentSource"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "DeploymentExternalValueSource" ADD CONSTRAINT "DeploymentExternalValueSource_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/apps/server/src/prisma/schema/project.prisma b/apps/server/src/prisma/schema/project.prisma index 6bcc5ce949..94d33c7894 100644 --- a/apps/server/src/prisma/schema/project.prisma +++ b/apps/server/src/prisma/schema/project.prisma @@ -12,17 +12,43 @@ model Deployment { } model DeploymentSource { - id String @id @unique @default(uuid()) @db.Uuid - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - deploymentId String @db.Uuid - repositoryId String @db.Uuid - type DeploymentSourceType - targetRevision String @default("") - path String @default("") - helmValuesFiles String @default("") - repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade) - deployment Deployment @relation(fields: [deploymentId], references: [id], onDelete: Cascade) + id String @id @unique @default(uuid()) @db.Uuid + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + deploymentId String @db.Uuid + repositoryId String @db.Uuid + type DeploymentSourceType + targetRevision String @default("") + path String @default("") + helmValuesFiles String @default("") + repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade) + deployment Deployment @relation(fields: [deploymentId], references: [id], onDelete: Cascade) + internalValueSources DeploymentInternalValueSource[] + externalValueSource DeploymentExternalValueSource? +} + +model DeploymentInternalValueSource { + id String @id @unique @default(uuid()) @db.Uuid + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + deploymentSourceId String @db.Uuid + order Int + path String @default("") + deploymentSource DeploymentSource @relation(fields: [deploymentSourceId], references: [id], onDelete: Cascade) +} + +model DeploymentExternalValueSource { + id String @id @unique @default(uuid()) @db.Uuid + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + deploymentSourceId String @unique @db.Uuid + order Int + path String @default("") + ref String + targetRevision String @default("") + repositoryId String @db.Uuid + deploymentSource DeploymentSource @relation(fields: [deploymentSourceId], references: [id], onDelete: Cascade) + repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade) } model Environment { @@ -46,20 +72,21 @@ model Environment { } model Repository { - id String @id @default(uuid()) @db.Uuid - projectId String @db.Uuid - internalRepoName String - externalRepoUrl String @default("") - externalUserName String @default("") - isInfra Boolean @default(false) - isPrivate Boolean @default(false) - deployRevision String @default("") - deployPath String @default("") - helmValuesFiles String @default("") - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - project Project @relation(fields: [projectId], references: [id], onDelete: Cascade) - deploymentSources DeploymentSource[] + id String @id @default(uuid()) @db.Uuid + projectId String @db.Uuid + internalRepoName String + externalRepoUrl String @default("") + externalUserName String @default("") + isInfra Boolean @default(false) + isPrivate Boolean @default(false) + deployRevision String @default("") + deployPath String @default("") + helmValuesFiles String @default("") + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + project Project @relation(fields: [projectId], references: [id], onDelete: Cascade) + deploymentSources DeploymentSource[] + deploymentExternalValueSources DeploymentExternalValueSource[] } model ProjectClusterHistory { diff --git a/packages/test-utils/src/imports/data.ts b/packages/test-utils/src/imports/data.ts index e7bc172877..058028f95f 100644 --- a/packages/test-utils/src/imports/data.ts +++ b/packages/test-utils/src/imports/data.ts @@ -2302,4 +2302,6 @@ export const data = { ], deployment: [], deploymentSource: [], + deploymentExternalValueSource: [], + deploymentInternalValueSource: [], }