mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
Detect when postgres is used instead of postgresql.
This commit is contained in:
parent
0db29719b0
commit
6833a5bdb0
@ -4,10 +4,15 @@ import { subMinutes } from 'date-fns';
|
|||||||
import { MYSQL, POSTGRESQL, MYSQL_DATE_FORMATS, POSTGRESQL_DATE_FORMATS } from 'lib/constants';
|
import { MYSQL, POSTGRESQL, MYSQL_DATE_FORMATS, POSTGRESQL_DATE_FORMATS } from 'lib/constants';
|
||||||
|
|
||||||
export function getDatabase() {
|
export function getDatabase() {
|
||||||
return (
|
const type =
|
||||||
process.env.DATABASE_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) {
|
export function getDateQuery(db, field, unit, timezone) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "0.22.0",
|
"version": "0.23.0",
|
||||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||||
"author": "Mike Cao <mike@mikecao.com>",
|
"author": "Mike Cao <mike@mikecao.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -2,14 +2,25 @@ require('dotenv').config();
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const databaseType =
|
function getDatabase() {
|
||||||
process.env.DATABASE_TYPE || (process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0]);
|
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)) {
|
if (!databaseType || !['mysql', 'postgresql'].includes(databaseType)) {
|
||||||
throw new Error('Missing or invalid database');
|
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 src = path.resolve(__dirname, `../prisma/schema.${databaseType}.prisma`);
|
||||||
const dest = path.resolve(__dirname, '../prisma/schema.prisma');
|
const dest = path.resolve(__dirname, '../prisma/schema.prisma');
|
||||||
|
Loading…
Reference in New Issue
Block a user