Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix semver error

Francis Cao3b792720af29
diff --git a/scripts/check-db.js b/scripts/check-db.js
index 100cba031..434a52b66 100644
--- a/scripts/check-db.js
+++ b/scripts/check-db.js
@@ -3,10 +3,10 @@ import 'dotenv/config';
import { execSync } from 'node:child_process';
import { PrismaPg } from '@prisma/adapter-pg';
import chalk from 'chalk';
-import semver from 'semver';
import { PrismaClient } from '../generated/prisma/client.js';
const MIN_VERSION = '9.4.0';
+const MIN_VERSION_NUM = 90400;
if (process.env.SKIP_DB_CHECK) {
console.log('Skipping database check.');
@@ -53,10 +53,14 @@ async function checkConnection() {
}
async function checkDatabaseVersion() {
- const query = await prisma.$queryRaw`select version() as version`;
- const version = semver.valid(semver.coerce(query[0].version));
+ const query = await prisma.$queryRaw`select current_setting('server_version_num') as version_num`;
+ const version = Number(query[0]?.version_num);
- if (semver.lt(version, MIN_VERSION)) {
+ if (!Number.isFinite(version)) {
+ throw new Error('Unable to determine database version.');
+ }
+
+ if (version < MIN_VERSION_NUM) {
throw new Error(
`Database version is not compatible. Please upgrade to ${MIN_VERSION} or greater.`,
);