* Correct installation documentation * Add stylized titles * Add some changes to the getting started documentation * Add changes for the backend guide * Add changes for the design guide * Add testing / Q&A guide improvements * Minor fixes to contributing docs * More improvements to the general doc * Improvements for frontend guide
2.2 KiB
| title |
|---|
| PostgreSQL |
Setup your application with PostgreSQL
Follow the instructions in the installation guide below that corresponds to your operating system:
- macOS
- Postgres.app: PostgreSQL installation as a Mac app
- Homebrew: if you use Homebrew you can easily install PostgreSQL with
brew install postgresql
- Linux (Ubuntu)
- Windows
You can find all installation options for a variety of operating systems on the official PostgreSQL download page.
Configuration
By default the application is configured to connect to a local database named PracticalDeveloper_development. If you need to specify a username and a password you can go about it by using the environment variable DATABASE_URL with a connection string.
The official Rails guides go into depth on how Rails merges the existing database.yml with the connection string.
Setup DATABASE_URL in application.yml
-
Open your
config/application.yml -
Add the following:
DATABASE_URL: postgresql://USERNAME:PASSWORD@localhost
- Replace
USERNAMEwith your database username,PASSWORDwith your database password.
You can find more details on connection strings in PostgreSQL's own documentation.
NOTE: due to how Rails merges database.yml and DATABASE_URL it's recommended not to add the database name in the connection string. This will default to your development database name also during tests, which will effectively empty the development DB each time tests are run.
Troubleshooting tests
- While running test cases, if you get an error message
postgresql connection timeout, please re-run the tests by increasing the statement timeout, for example:
STATEMENT_TIMEOUT=10000 bundle exec rspec