From c32baa08080b0e4eeb2fa3e946ddf74eacc51491 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 3 Jul 2023 18:05:11 +0900 Subject: [PATCH 1/2] Set environments used in redmine_check_database_connection only --- assets/runtime/functions | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/assets/runtime/functions b/assets/runtime/functions index 3ac31794..fe741895 100644 --- a/assets/runtime/functions +++ b/assets/runtime/functions @@ -150,20 +150,23 @@ redmine_finalize_database_parameters() { DB_PASS=${DB_PASS:-${POSTGRESQL_ENV_PASS}} DB_NAME=${DB_NAME:-${POSTGRESQL_ENV_DB}} elif [[ -n ${DATABASE_URL} ]]; then + # Set environments for redmine_check_database_connection case $(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).scheme') in - postgres*) + postgres | postgresql) DB_ADAPTER=${DB_ADAPTER:-postgresql} DB_HOST=${DB_HOST:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).hostname')} + DB_PORT=${DB_PORT:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).port || 5432')} DB_USER=${DB_USER:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).user')} - DB_PASS=${DB_PASS:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).password')} - DB_NAME=${DB_NAME:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).path.delete_prefix("/")')} ;; - mysql*) + mysql2) DB_ADAPTER=${DB_ADAPTER:-mysql2} DB_HOST=${DB_HOST:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).hostname')} + DB_PORT=${DB_PORT:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).port || 3306')} DB_USER=${DB_USER:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).user')} DB_PASS=${DB_PASS:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).password')} - DB_NAME=${DB_NAME:-$(ruby -r uri -e 'puts URI(ENV["DATABASE_URL"]).path.delete_prefix("/")')} + ;; + sqlite3) + DB_ADAPTER=${DB_ADAPTER:-sqlite3} ;; esac fi From 787800e9f868d43bfe5a8365cb292353094af9bd Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Mon, 3 Jul 2023 18:06:19 +0900 Subject: [PATCH 2/2] Add DATABASE_URL to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fe10cb52..9dd8d726 100644 --- a/README.md +++ b/README.md @@ -619,6 +619,7 @@ Below is the complete list of parameters that can be set using environment varia - **REDMINE_BACKUP_SCHEDULE**: Setup cron job to schedule automatic backups. Possible values `disable`, `daily`, `weekly` or `monthly`. Disabled by default - **REDMINE_BACKUP_EXPIRY**: Configure how long (in seconds) to keep backups before they are deleted. By default when automated backups are disabled backups are kept forever (0 seconds), else the backups expire in 7 days (604800 seconds). - **REDMINE_BACKUP_TIME**: Set a time for the automatic backups in `HH:MM` format. Defaults to `04:00`. +- **DATABASE_URL**: The database URL. See [Configuring a Database](https://guides.rubyonrails.org/configuring.html#configuring-a-database). Possible schemes: `postgres`, `postgresql`, `mysql2`, and `sqlite3`. Defaults to no URL. - **DB_ADAPTER**: The database type. Possible values: `mysql2`, `postgresql`, and 'sqlite3'. Defaults to `mysql`. - **DB_ENCODING**: The database encoding. For `DB_ADAPTER` values `postresql` and `mysql2`, this parameter defaults to `unicode` and `utf8` respectively. - **DB_HOST**: The database server hostname. Defaults to `localhost`.