mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: add fullContext column to rollback table and update related functionality
- Introduced a new "fullContext" JSONB column in the "rollback" table to store additional context for rollbacks. - Removed the "env" column from the "rollback" table to streamline data management. - Updated the rollbacks service to handle the new "fullContext" field during rollback creation. - Adjusted the application service to eliminate environment variable handling in rollback operations.
This commit is contained in:
@@ -41,10 +41,7 @@ import {
|
||||
import { createTraefikConfig } from "@dokploy/server/utils/traefik/application";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import {
|
||||
encodeBase64,
|
||||
prepareEnvironmentVariables,
|
||||
} from "../utils/docker/utils";
|
||||
import { encodeBase64 } from "../utils/docker/utils";
|
||||
import { getDokployUrl } from "./admin";
|
||||
import {
|
||||
createDeployment,
|
||||
@@ -219,14 +216,8 @@ export const deployApplication = async ({
|
||||
await updateApplicationStatus(applicationId, "done");
|
||||
|
||||
if (application.rollbackActive) {
|
||||
const resolveEnvs = prepareEnvironmentVariables(
|
||||
application.env,
|
||||
application.project.env,
|
||||
);
|
||||
|
||||
await createRollback({
|
||||
appName: application.appName,
|
||||
env: resolveEnvs.join("\n"),
|
||||
deploymentId: deployment.deploymentId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,23 +24,24 @@ export const createRollback = async (
|
||||
}
|
||||
|
||||
const tagImage = `${input.appName}:v${rollback.version}`;
|
||||
|
||||
await tx
|
||||
.update(rollbacks)
|
||||
.set({
|
||||
image: tagImage,
|
||||
})
|
||||
.where(eq(rollbacks.rollbackId, rollback.rollbackId));
|
||||
|
||||
const deployment = await findDeploymentById(rollback.deploymentId);
|
||||
|
||||
if (!deployment?.applicationId) {
|
||||
throw new Error("Deployment not found");
|
||||
}
|
||||
|
||||
const application = await findApplicationById(deployment.applicationId);
|
||||
const { deployments, bitbucket, github, gitlab, gitea, ...rest } =
|
||||
await findApplicationById(deployment.applicationId);
|
||||
|
||||
await createRollbackImage(application, tagImage);
|
||||
await tx
|
||||
.update(rollbacks)
|
||||
.set({
|
||||
image: tagImage,
|
||||
fullContext: JSON.stringify(rest),
|
||||
})
|
||||
.where(eq(rollbacks.rollbackId, rollback.rollbackId));
|
||||
|
||||
await createRollbackImage(rest, tagImage);
|
||||
|
||||
return rollback;
|
||||
});
|
||||
@@ -123,7 +124,6 @@ export const rollback = async (rollbackId: string) => {
|
||||
await rollbackApplication(
|
||||
application.appName,
|
||||
result.image || "",
|
||||
result.env || "",
|
||||
application.serverId,
|
||||
);
|
||||
};
|
||||
@@ -131,7 +131,6 @@ export const rollback = async (rollbackId: string) => {
|
||||
const rollbackApplication = async (
|
||||
appName: string,
|
||||
image: string,
|
||||
env: string,
|
||||
serverId?: string | null,
|
||||
) => {
|
||||
const docker = await getRemoteDocker(serverId);
|
||||
@@ -141,7 +140,6 @@ const rollbackApplication = async (
|
||||
TaskTemplate: {
|
||||
ContainerSpec: {
|
||||
Image: image,
|
||||
// Env: env.split("\n"),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user