refactor: restructure application and rollback context to encapsulate project within environment, improving data organization and clarity across services

This commit is contained in:
Mauricio Siu
2025-09-01 23:19:53 -06:00
parent c57c231c32
commit e8a5f9c0a8
3 changed files with 12 additions and 4 deletions

View File

@@ -20,7 +20,11 @@ export default async function handler(
const application = await db.query.applications.findFirst({
where: eq(applications.refreshToken, refreshToken as string),
with: {
project: true,
environment: {
with: {
project: true,
},
},
bitbucket: true,
},
});

View File

@@ -27,7 +27,9 @@ export const rollbacks = pgTable("rollback", {
.$defaultFn(() => new Date().toISOString()),
fullContext: jsonb("fullContext").$type<
Application & {
project: Project;
environment: {
project: Project;
};
mounts: Mount[];
ports: Port[];
registry?: Registry | null;

View File

@@ -179,7 +179,9 @@ const rollbackApplication = async (
image: string,
serverId?: string | null,
fullContext?: Application & {
project: Project;
environment: {
project: Project;
};
mounts: Mount[];
ports: Port[];
},
@@ -225,7 +227,7 @@ const rollbackApplication = async (
const bindsMount = generateBindMounts(mounts);
const envVariables = prepareEnvironmentVariables(
env,
fullContext.project.env,
fullContext.environment.project.env,
);
// For rollback, we use the provided image instead of calculating it