Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Umami to be configured with UMAMI_DATABASE_URL #3165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scripts/check-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (process.env.SKIP_DB_CHECK) {
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];

if (type === 'postgres') {
Expand All @@ -31,10 +31,10 @@ function error(msg) {
}

async function checkEnv() {
if (!process.env.DATABASE_URL) {
throw new Error('DATABASE_URL is not defined.');
if (!process.env.UMAMI_DATABASE_URL && !process.env.DATABASE_URL) {
throw new Error('Neither UMAMI_DATABASE_URL nor DATABASE_URL is defined.');
} else {
success('DATABASE_URL is defined.');
success('Database URL is defined.');
}
}

Expand Down
5 changes: 4 additions & 1 deletion scripts/check-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ function checkMissing(vars) {
}

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) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/copy-db-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fse = require('fs-extra');
const path = require('path');
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]);

if (type === 'postgres') {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BigInt.prototype['toJSON'] = function () {
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];

if (type === 'postgres') {
Expand Down