Allow Umami to be configured with UMAMI_DATABASE_URL

This commit is contained in:
Luiz Eduardo Kowalski 2025-01-08 10:52:10 -03:00
parent bce70c1034
commit acc3f10284
4 changed files with 10 additions and 7 deletions

View file

@ -10,7 +10,7 @@ if (process.env.SKIP_DB_CHECK) {
process.exit(0); process.exit(0);
} }
function getDatabaseType(url = process.env.DATABASE_URL) { function getDatabaseType(url = process.env.UMAMI_DATABASE_URL || process.env.DATABASE_URL) {
const type = url && url.split(':')[0]; const type = url && url.split(':')[0];
if (type === 'postgres') { if (type === 'postgres') {
@ -31,10 +31,10 @@ function error(msg) {
} }
async function checkEnv() { async function checkEnv() {
if (!process.env.DATABASE_URL) { if (!process.env.UMAMI_DATABASE_URL && !process.env.DATABASE_URL) {
throw new Error('DATABASE_URL is not defined.'); throw new Error('Neither UMAMI_DATABASE_URL nor DATABASE_URL is defined.');
} else { } else {
success('DATABASE_URL is defined.'); success('Database URL is defined.');
} }
} }

View file

@ -19,7 +19,10 @@ function checkMissing(vars) {
} }
if (!process.env.SKIP_DB_CHECK && !process.env.DATABASE_TYPE) { if (!process.env.SKIP_DB_CHECK && !process.env.DATABASE_TYPE) {
checkMissing(['DATABASE_URL']); if (!process.env.UMAMI_DATABASE_URL && !process.env.DATABASE_URL) {
console.log('Neither UMAMI_DATABASE_URL nor DATABASE_URL is defined.');
process.exit(1);
}
} }
if (process.env.CLOUD_MODE) { if (process.env.CLOUD_MODE) {

View file

@ -4,7 +4,7 @@ const fse = require('fs-extra');
const path = require('path'); const path = require('path');
const del = require('del'); const del = require('del');
function getDatabaseType(url = process.env.DATABASE_URL) { function getDatabaseType(url = process.env.UMAMI_DATABASE_URL || process.env.DATABASE_URL) {
const type = process.env.DATABASE_TYPE || (url && url.split(':')[0]); const type = process.env.DATABASE_TYPE || (url && url.split(':')[0]);
if (type === 'postgres') { if (type === 'postgres') {

View file

@ -10,7 +10,7 @@ BigInt.prototype['toJSON'] = function () {
return Number(this); return Number(this);
}; };
export function getDatabaseType(url = process.env.DATABASE_URL) { export function getDatabaseType(url = process.env.UMAMI_DATABASE_URL || process.env.DATABASE_URL) {
const type = url && url.split(':')[0]; const type = url && url.split(':')[0];
if (type === 'postgres') { if (type === 'postgres') {