Release v2.6.22

This commit is contained in:
2026-08-09 13:06:02 +01:00
parent c36b9122c9
commit 6d8bf0f5f0
8 changed files with 154 additions and 12 deletions
+3 -2
View File
@@ -1,5 +1,5 @@
const { version: appVersion } = require('#root/package.json');
const { compareVersions, detectSchemaVersion, recordSchemaVersion, runMigrations } = require('./migrations');
const { compareVersions, detectSchemaVersion, getPendingMigrations, recordSchemaVersion, runMigrations } = require('./migrations');
// Snapshot only: keep this file aligned with the current schema state.
async function ensureSchema(pool, options) {
@@ -16,7 +16,8 @@ async function ensureSchema(pool, options) {
try {
const currentVersion = await detectSchemaVersion(pool);
const updateRequired = compareVersions(currentVersion, appVersion) < 0;
const pendingMigrations = await getPendingMigrations(pool, { currentVersion: currentVersion });
const updateRequired = pendingMigrations.length > 0;
console.info('[schema] previous=' + currentVersion + ' current=' + appVersion + ' update=' + (updateRequired ? 'yes' : 'no'));
+13 -6
View File
@@ -806,8 +806,7 @@ function compareVersions(leftVersion, rightVersion) {
return 0;
}
async function runMigrations(pool, options) {
// Only run migrations that are newer than the installed schema version and not beyond the app version.
async function getPendingMigrations(pool, options) {
const targetVersion = String(appVersion || '0.0.0').trim();
const currentVersion = String(options && options.currentVersion || '0.0.0').trim();
const legacyPlayerSchemaPresent = await columnExists(pool, 'd_players', 'device_id');
@@ -828,15 +827,23 @@ async function runMigrations(pool, options) {
effectiveCurrentVersion = compareVersions(effectiveCurrentVersion, '2.6.18') < 0 ? '2.6.17' : '2.6.17';
}
for (const migration of VERSIONED_MIGRATIONS) {
if (compareVersions(migration.version, effectiveCurrentVersion) > 0 && compareVersions(migration.version, targetVersion) <= 0) {
await migration.run(pool);
}
return VERSIONED_MIGRATIONS.filter(function (migration) {
return compareVersions(migration.version, effectiveCurrentVersion) > 0 && compareVersions(migration.version, targetVersion) <= 0;
});
}
async function runMigrations(pool, options) {
// Only run migrations that are newer than the installed schema version and not beyond the app version.
const pendingMigrations = await getPendingMigrations(pool, options);
for (const migration of pendingMigrations) {
await migration.run(pool);
}
}
module.exports = {
appVersion: appVersion,
getPendingMigrations: getPendingMigrations,
runMigrations: runMigrations,
detectSchemaVersion: detectSchemaVersion,
recordSchemaVersion: recordSchemaVersion,