mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-03-02 22:57:00 -05:00
Problem connecting to database with env var #2778
Labels
No labels
A:accessibility
A:api
A:cert-expiry
A:core
A:dashboard
A:deployment
A:documentation
A:domain expiry
A:incidents
A:maintenance
A:metrics
A:monitor
A:notifications
A:reports
A:settings
A:status-page
A:ui/ux
A:user-management
Stale
ai-slop
blocked
blocked-upstream
bug
cannot-reproduce
dependencies
discussion
duplicate
feature-request
feature-request
good first issue
hacktoberfest
help
help wanted
house keeping
invalid
invalid-format
invalid-format
question
releaseblocker 🚨
security
spam
type:enhance-existing
type:new
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/uptime-kuma#2778
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vonbarnekowa on GitHub (Nov 13, 2023).
⚠️ Please verify that this bug has NOT been raised before.
🛡️ Security Policy
Description
When I run Uptime Kuma with the UPTIME_KUMA_DB_PORT, UPTIME_KUMA_DB_PASSWORD, UPTIME_KUMA_DB_NAME, UPTIME_KUMA_DB_TYPE and UPTIME_KUMA_DB_HOSTNAME environment variables, I can't get the application to work. I get the following error:
[2023-11-13 07:48:55] 2023-11-13T07:48:55Z [DB] ERROR: Database migration failed [2023-11-13 07:48:55] 2023-11-13T07:48:55Z [SERVER] ERROR: Failed to prepare your database: create table knex_migrations (id int unsigned not null auto_increment primary key, name varchar(255), batch int, migration_time timestamp) - No database selectedI don't understand because the tables already exist in the database of a previous installation. I've also tried to create a new database but I get the same errors.
I guess there must be a problem loading the values.
(Moreover, the existence of these env variables is not documented.)
👟 Reproduction steps
👀 Expected behavior
The desired behavior is that the values passed by the environment variables are used. In addition, it should detect that values already exist and skip the table creation part.
😓 Actual Behavior
It displays an error indicating that no database has been set.
🐻 Uptime-Kuma Version
1.23.3
💻 Operating System and Arch
--
🌐 Browser
Brave 1.59.122
🐋 Docker Version
--
🟩 NodeJS Version
v21.1.0
📝 Relevant log output
No response
@louislam commented on GitHub (Nov 13, 2023):
I think you should follow the installation guide again and install it correctly, because it is not in the 1.23.X version.
@vonbarnekowa commented on GitHub (Nov 13, 2023):
The place where I deploy this has no persistence to store the db-config.json and it's overkill to mount an s3 on purpose for a single file. If I don't do it with environment variables, I always have to reconfigure the database when my container restarts.
Isn't it simpler to try to make the existing codebase work? Especially as it's really useful to be able to use environment variables. I imagine I'm not the only one who wants this.
But if you say you're not going to make any changes, I'll adapt the code on my side. It's not a big deal, I'm just trying to get the codebase working as expected so that the project becomes even better.
@vonbarnekowa commented on GitHub (Nov 13, 2023):
The problem comes from the
server/setup-database.jsfile on line 77. It should bedbConfig.dbName = process.env.UPTIME_KUMA_DB_NAME;instead of
dbConfig.database = process.env.UPTIME_KUMA_DB_NAME;I'm going to test everything and make a PR if you think it's useful.
@louislam commented on GitHub (Nov 13, 2023):
Since you said
1.23.3, I assumed that you didn't installed correctly.What you are looking at is the code from dev (2.0.X) branch, they are unreleased and unstable. They are under development and maybe it is actually a bug. I highly recommend that you should not use that for production for any reasons.
@vonbarnekowa commented on GitHub (Nov 13, 2023):
I'm using version 1.23.3. I simply forked the
masterbranch which seems to be in this version. I don't see anything from 2.0.X.Line
@chakflying commented on GitHub (Nov 13, 2023):
The master branch has been 2.0 since #2720 was merged. Yes you have found a bug, but even if you fix that line, the code still expects the config to be written to the json file. I don't think you can trivially fix this, and there may be other known or unknown bugs that are not fixed yet.
If you just want to use the application, please follow the installation guide and
checkout 1.23.4.