Hub 2.23.1: a church's Accounts version comes from its heartbeat
New install checked the install record's version, which only changed with the Hub's own jobs for that product. Accounts updated alongside Events 3.7.0 still showed 1.6.0 there, so New install -> Website refused cross-demo2 while the installs list showed 1.7.0. It now uses the heartbeat's version, and each heartbeat updates the record's version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -239,6 +239,9 @@ router.post('/installs/heartbeat', heartbeatLimiter, async (req, res) => {
|
||||
try {
|
||||
const tied = await prisma.deployment.updateMany({ where: { licenceId: install.licenceId, installId: null, status: { notIn: ['removed', 'failed'] } }, data: { installId: install.id } });
|
||||
if (!tied.count) await require('../utils/jobs').lookForUnlinked(install, now);
|
||||
// Hub 2.23.1: the install record's version follows the heartbeat (it only followed the Hub's
|
||||
// own jobs, so a product updated alongside another kept its old version there).
|
||||
if (version) await prisma.deployment.updateMany({ where: { installId: install.id, OR: [{ version: null }, { version: { not: version } }] }, data: { version } });
|
||||
} catch (e) {
|
||||
console.warn('[hub] tying the install record to its site failed:', e?.message || e);
|
||||
}
|
||||
|
||||
@@ -672,7 +672,7 @@ async function newInstall(input, admin, now = new Date()) {
|
||||
const release = await releaseFor(product, input.version || null);
|
||||
await preflight(server, product, release.version, now);
|
||||
// The church's other products: the same short name means the same church folder on one server.
|
||||
const siblings = await prisma.deployment.findMany({ where: { shortName, status: { notIn: ['removed', 'failed'] } } });
|
||||
const siblings = await prisma.deployment.findMany({ where: { shortName, status: { notIn: ['removed', 'failed'] } }, include: { install: true } });
|
||||
if (siblings.some(s => s.product === product)) throw fail(409, 'SHORT_NAME_TAKEN', `${shortName} already has ${PRODUCT_NAMES[product]}.`);
|
||||
if (siblings.some(s => s.customerId !== customer.id)) throw fail(409, 'SHORT_NAME_TAKEN', `The short name ${shortName} is already used by another customer.`);
|
||||
if (siblings.some(s => s.serverId !== server.id)) throw fail(409, 'OTHER_SERVER', `${shortName}'s other products are on another server; a church's products go on one server.`);
|
||||
@@ -942,8 +942,12 @@ async function requiredFirst({ release, product, siblings, input, domain, server
|
||||
if (!need) return null;
|
||||
const have = siblings.find(s => s.product === 'accounts');
|
||||
if (have) {
|
||||
if (have.version && compareVersions(have.version, need.version) < 0) {
|
||||
throw fail(409, 'REQUIREMENT_NOT_MET', `${PRODUCT_NAMES[product]} ${release.version} needs Accounts ${need.version} or later; this church has ${have.version}. Update its Accounts first.`);
|
||||
// Hub 2.23.1: what it runs now, from its heartbeat. The record's version only changes with the
|
||||
// Hub's own jobs, so an Accounts updated alongside another product (crosscode deploy updates
|
||||
// Accounts first) still showed the old one.
|
||||
const running = have.install?.version || have.version;
|
||||
if (running && compareVersions(running, need.version) < 0) {
|
||||
throw fail(409, 'REQUIREMENT_NOT_MET', `${PRODUCT_NAMES[product]} ${release.version} needs Accounts ${need.version} or later; this church has ${running}. Update its Accounts first.`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user