feat(deployment): add deployment history and rollback support
This commit is contained in:
1 parent
029b25b596
commit
4e9b173edb
36 files changed
+3663
-569
No files matched your search
@@ -0,0 +1,38 @@
|
||||
CREATE TYPE "DeploymentStatus" AS ENUM ('QUEUED', 'RUNNING', 'SUCCESS', 'FAILED', 'CANCELLED', 'ROLLED_BACK');
|
||||
|
||||
CREATE TYPE "DeploymentTrigger" AS ENUM ('MANUAL', 'GIT_WEBHOOK', 'REBUILD', 'ROLLBACK', 'APP_INSTALLER');
|
||||
|
||||
CREATE TABLE "deployments" (
|
||||
"id" TEXT NOT NULL,
|
||||
"containerId" TEXT NOT NULL,
|
||||
"organizationId" TEXT NOT NULL,
|
||||
"serverId" TEXT NOT NULL,
|
||||
"userId" TEXT,
|
||||
"status" "DeploymentStatus" NOT NULL,
|
||||
"trigger" "DeploymentTrigger" NOT NULL,
|
||||
"version" TEXT,
|
||||
"commitSha" TEXT,
|
||||
"branch" TEXT,
|
||||
"image" TEXT,
|
||||
"imageDigest" TEXT,
|
||||
"configSnapshot" JSONB NOT NULL,
|
||||
"error" TEXT,
|
||||
"startedAt" TIMESTAMP(3),
|
||||
"completedAt" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "deployments_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE INDEX "deployments_containerId_createdAt_idx" ON "deployments"("containerId", "createdAt");
|
||||
CREATE INDEX "deployments_organizationId_createdAt_idx" ON "deployments"("organizationId", "createdAt");
|
||||
CREATE INDEX "deployments_serverId_createdAt_idx" ON "deployments"("serverId", "createdAt");
|
||||
|
||||
ALTER TABLE "deployments" ADD CONSTRAINT "deployments_containerId_fkey"
|
||||
FOREIGN KEY ("containerId") REFERENCES "containers"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "deployments" ADD CONSTRAINT "deployments_organizationId_fkey"
|
||||
FOREIGN KEY ("organizationId") REFERENCES "organizations"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "deployments" ADD CONSTRAINT "deployments_serverId_fkey"
|
||||
FOREIGN KEY ("serverId") REFERENCES "servers"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "deployments" ADD CONSTRAINT "deployments_userId_fkey"
|
||||
FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE "deployment_locks" (
|
||||
"containerId" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"expiresAt" TIMESTAMP(3) NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "deployment_locks_pkey" PRIMARY KEY ("containerId")
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX "deployment_locks_token_key" ON "deployment_locks"("token");
|
||||
CREATE INDEX "deployment_locks_expiresAt_idx" ON "deployment_locks"("expiresAt");
|
||||
|
||||
ALTER TABLE "deployment_locks" ADD CONSTRAINT "deployment_locks_containerId_fkey"
|
||||
FOREIGN KEY ("containerId") REFERENCES "containers"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE "deployments"
|
||||
ADD COLUMN "rollbackSnapshotEnc" TEXT;
|
||||
+66
-1
@@ -31,6 +31,7 @@ model User {
|
||||
createdOrganizations Organization[] @relation("OrganizationCreator")
|
||||
apiKeys ApiKey[]
|
||||
auditLogs AuditLog[]
|
||||
deployments Deployment[]
|
||||
settings UserSettings?
|
||||
notificationProviders UserNotificationProvider[]
|
||||
integrations UserIntegration[]
|
||||
@@ -61,6 +62,7 @@ model Organization {
|
||||
apiKeys ApiKey[]
|
||||
invitations UserInvitation[]
|
||||
auditLogs AuditLog[]
|
||||
deployments Deployment[]
|
||||
|
||||
@@index([createdById])
|
||||
@@map("organizations")
|
||||
@@ -397,6 +399,7 @@ model Server {
|
||||
storageDestinations UserStorageDestination[]
|
||||
domains Domain[]
|
||||
auditLogs AuditLog[]
|
||||
deployments Deployment[]
|
||||
metrics ServerMetric[]
|
||||
appInstalls AppInstall[]
|
||||
backups Backup[]
|
||||
@@ -456,6 +459,8 @@ model Container {
|
||||
environment Environment? @relation(fields: [environmentId], references: [id], onDelete: SetNull)
|
||||
domains Domain[]
|
||||
deploymentSource ContainerDeploymentSource?
|
||||
deployments Deployment[]
|
||||
deploymentLock DeploymentLock?
|
||||
ports Json @default("[]") // [{host: 80, container: 80, protocol: "tcp"}]
|
||||
envVars Json @default("[]") // [{key: "NODE_ENV", value: "production"}]
|
||||
volumes Json @default("[]")
|
||||
@@ -501,6 +506,67 @@ model ContainerDeploymentSource {
|
||||
@@map("container_deployment_sources")
|
||||
}
|
||||
|
||||
model Deployment {
|
||||
id String @id @default(cuid())
|
||||
containerId String
|
||||
organizationId String
|
||||
serverId String
|
||||
userId String?
|
||||
status DeploymentStatus
|
||||
trigger DeploymentTrigger
|
||||
version String?
|
||||
commitSha String?
|
||||
branch String?
|
||||
image String?
|
||||
imageDigest String?
|
||||
configSnapshot Json
|
||||
rollbackSnapshotEnc String?
|
||||
error String?
|
||||
startedAt DateTime?
|
||||
completedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
container Container @relation(fields: [containerId], references: [id], onDelete: Cascade)
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([containerId, createdAt])
|
||||
@@index([organizationId, createdAt])
|
||||
@@index([serverId, createdAt])
|
||||
@@map("deployments")
|
||||
}
|
||||
|
||||
model DeploymentLock {
|
||||
containerId String @id
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
container Container @relation(fields: [containerId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([expiresAt])
|
||||
@@map("deployment_locks")
|
||||
}
|
||||
|
||||
enum DeploymentStatus {
|
||||
QUEUED
|
||||
RUNNING
|
||||
SUCCESS
|
||||
FAILED
|
||||
CANCELLED
|
||||
ROLLED_BACK
|
||||
}
|
||||
|
||||
enum DeploymentTrigger {
|
||||
MANUAL
|
||||
GIT_WEBHOOK
|
||||
REBUILD
|
||||
ROLLBACK
|
||||
APP_INSTALLER
|
||||
}
|
||||
|
||||
model Network {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
@@ -781,4 +847,3 @@ enum BackupStatus {
|
||||
COMPLETED
|
||||
FAILED
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user