Skip to content

Commit 5a0d55d

Browse files
authored
Merge pull request #7228 from FlowFuse/auto-update-stack-to-latest
Ensure auto updating stacks jump to latest version
2 parents 7816b98 + 8cfc04b commit 5a0d55d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

forge/db/models/ProjectStack.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ module.exports = {
108108
instance: {
109109
projectCount: async function () {
110110
return await M.Project.count({ where: { ProjectStackId: this.id } })
111+
},
112+
findLatestStack: async function () {
113+
if (this.replacedBy) {
114+
return (await M.ProjectStack.byId(this.replacedBy)).findLatestStack()
115+
} else {
116+
return this
117+
}
111118
}
112119
}
113120
}

forge/ee/lib/autoUpdateStacks/tasks/upgrade-stack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
if (project.Project.ProjectStack.replacedBy) {
2626
// need to add audit logging
2727
try {
28-
const newStack = await app.db.models.ProjectStack.byId(project.Project.ProjectStack.replacedBy)
28+
const newStack = await project.Project.ProjectStack.findLatestStack()
2929
app.log.info(`Updating project ${project.Project.id} to stack: '${newStack.hashid}'`)
3030

3131
const suspendOptions = {

0 commit comments

Comments
 (0)