diff --git a/config/environment.rb b/config/environment.rb index 7fe1dd82523..0af6391a727 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,13 @@ # Load the rails application require File.expand_path('application', __dir__) +# https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING +ENV['DATABASE_URL'] ||= case Rails.env + when 'production' + 'postgresql://' + else + "postgresql:///foreman-#{Rails.env}" + end + # Initialize the rails application Foreman::Application.initialize! diff --git a/developer_docs/foreman_dev_setup.asciidoc b/developer_docs/foreman_dev_setup.asciidoc index 503406fd311..bd877ec99a0 100644 --- a/developer_docs/foreman_dev_setup.asciidoc +++ b/developer_docs/foreman_dev_setup.asciidoc @@ -68,7 +68,6 @@ sudo -u postgres createuser --createdb $USER git clone https://github.com/{GITHUB_USER}/foreman.git -b develop cd foreman cp config/settings.yaml.example config/settings.yaml -cp config/database.yml.example config/database.yml git remote add upstream git@github.com:theforeman/foreman.git .... @@ -106,8 +105,6 @@ Foreman uses Bundler to install dependencies and get up and running. This is the [[Database]] == Setting the database -It is important that config/database.yml is set to use the correct database in the “development” block. -Rails (and subsequently Foreman) will use these connection settings under “development” to manage the database it uses and setup the necessary schema. Set up database schema: [source, ruby] diff --git a/lib/tasks/backup.rake b/lib/tasks/backup.rake index d2b0ef48ecc..0960c9a4642 100644 --- a/lib/tasks/backup.rake +++ b/lib/tasks/backup.rake @@ -5,7 +5,6 @@ namespace :db do Make a dump of your database Foreman will make a dump of your database at the provided location, or it will put it in #{File.expand_path('../../db', __dir__)} if no destination file is provided. - A valid config/database.yml file with the database details is needed to perform this operation. Available conditions: * destination => path to dump output file (defaults to #{File.expand_path('../../db', __dir__)}/foreman.EPOCH.sql) @@ -73,7 +72,6 @@ namespace :db do Import a database dump Foreman will import a database from the provided location. - A valid config/database.yml file with the database details is needed to perform this operation. Available conditions: * file => database dump file path