fix(server): wrong DB version (closes #9418)

This commit is contained in:
Elian Doran
2026-04-14 21:43:38 +03:00
parent ab00772559
commit 278da994ce
3 changed files with 21 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
import { describe, expect, it } from "vitest";
import MIGRATIONS from "./migrations.js";
describe("migrations", () => {
it("should have unique version numbers", () => {
const versions = MIGRATIONS.map((m) => m.version);
const uniqueVersions = new Set(versions);
expect(versions.length).toBe(uniqueVersions.size);
});
it("should be sorted in descending order by version", () => {
for (let i = 1; i < MIGRATIONS.length; i++) {
expect(MIGRATIONS[i - 1].version, `migration at index ${i - 1} (v${MIGRATIONS[i - 1].version}) should be greater than migration at index ${i} (v${MIGRATIONS[i].version})`).toBeGreaterThan(MIGRATIONS[i].version);
}
});
});

View File

@@ -344,6 +344,8 @@ const MIGRATIONS: (SqlMigration | JsMigration)[] = [
export default MIGRATIONS;
export const MAX_MIGRATION_VERSION = MIGRATIONS[0].version;
interface Migration {
version: number;
/** If true, errors during this migration are logged but do not halt the migration process. Useful for migrations that may have already been applied (e.g. adding a column that already exists). */

View File

@@ -2,16 +2,16 @@ import { AppInfo } from "@triliumnext/commons";
import path from "path";
import packageJson from "../../package.json" with { type: "json" };
import { MAX_MIGRATION_VERSION } from "../migrations/migrations.js";
import build from "./build.js";
import dataDir from "./data_dir.js";
const APP_DB_VERSION = 236;
const SYNC_VERSION = 38;
const CLIPPER_PROTOCOL_VERSION = "1.0";
export default {
appVersion: packageJson.version,
dbVersion: APP_DB_VERSION,
dbVersion: MAX_MIGRATION_VERSION,
nodeVersion: process.version,
syncVersion: SYNC_VERSION,
buildDate: build.buildDate,