feat: add ability to delete old deployments

This commit is contained in:
Marc Fernandez
2025-12-07 12:39:31 +01:00
parent f0400495b0
commit 33fb21bfe1
6 changed files with 234 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ import {
addDomainToCompose,
addNewService,
checkServiceAccess,
clearOldDeploymentsByComposeId,
cloneCompose,
createCommand,
createCompose,
@@ -252,6 +253,26 @@ export const composeRouter = createTRPCRouter({
await cleanQueuesByCompose(input.composeId);
return { success: true, message: "Queues cleaned successfully" };
}),
clearDeployments: protectedProcedure
.input(apiFindCompose)
.mutation(async ({ input, ctx }) => {
const compose = await findComposeById(input.composeId);
if (
compose.environment.project.organizationId !==
ctx.session.activeOrganizationId
) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You are not authorized to clear deployments for this compose",
});
}
const result = await clearOldDeploymentsByComposeId(input.composeId);
return {
success: true,
message: `${result.deletedCount} old deployments cleared successfully`,
deletedCount: result.deletedCount,
};
}),
killBuild: protectedProcedure
.input(apiFindCompose)
.mutation(async ({ input, ctx }) => {