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.

Detect when postgres is used instead of postgresql.

Mike Cao6833a5bdb0b8
diff --git a/lib/queries.js b/lib/queries.js
index 5b30c0a9c..684b30d4e 100644
--- a/lib/queries.js
+++ b/lib/queries.js
@@ -4,10 +4,15 @@ import { subMinutes } from 'date-fns';
import { MYSQL, POSTGRESQL, MYSQL_DATE_FORMATS, POSTGRESQL_DATE_FORMATS } from 'lib/constants';
export function getDatabase() {
- return (
+ const type =
process.env.DATABASE_TYPE ||
- (process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0])
- );
+ (process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0]);
+
+ if (type === 'postgres') {
+ return 'postgresql';
+ }
+
+ return type;
}
export function getDateQuery(db, field, unit, timezone) {
diff --git a/package.json b/package.json
index e43acc20b..2d58e380c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "umami",
- "version": "0.22.0",
+ "version": "0.23.0",
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao <[email protected]>",
"license": "MIT",
diff --git a/scripts/copy-db-schema.js b/scripts/copy-db-schema.js
index 2d480545f..7773e6966 100644
--- a/scripts/copy-db-schema.js
+++ b/scripts/copy-db-schema.js
@@ -2,14 +2,25 @@ require('dotenv').config();
const fs = require('fs');
const path = require('path');
-const databaseType =
- process.env.DATABASE_TYPE || (process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0]);
+function getDatabase() {
+ const type =
+ process.env.DATABASE_TYPE ||
+ (process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0]);
+
+ if (type === 'postgres') {
+ return 'postgresql';
+ }
+
+ return type;
+}
+
+const databaseType = getDatabase();
if (!databaseType || !['mysql', 'postgresql'].includes(databaseType)) {
throw new Error('Missing or invalid database');
}
-console.log(`Database schema detected: ${databaseType}`);
+console.log(`Database type detected: ${databaseType}`);
const src = path.resolve(__dirname, `../prisma/schema.${databaseType}.prisma`);
const dest = path.resolve(__dirname, '../prisma/schema.prisma');