Skip to content

Commit ec26d5e

Browse files
authored
Chore/test db setup (#199)
2 parents d41829b + 4ae8a99 commit ec26d5e

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

.env.example

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,3 @@ AWS_ENDPOINT_URL=http://localstack:4566
1717
AZURE_STORAGE_ACCOUNT_NAME=skillrx
1818
AZURE_STORAGE_ACCOUNT_KEY=skillrx
1919
AZURE_STORAGE_SHARE_NAME=skillrx
20-
21-
DATABASE_URL=postgres://@localhost:5432/skillrx_test
22-
QUEUE_DATABASE_URL=postgres://@localhost:5432/skillrx_test_queue

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@ jobs:
5959
test:
6060
runs-on: ubuntu-latest
6161
env:
62-
DATABASE_URL: postgres://postgres:postgres@localhost:5432/skillrx_test
63-
QUEUE_DATABASE_URL: postgres://postgres:postgres@localhost:5432/skillrx_test_queue
62+
DATABASE_USERNAME: 'postgres'
6463
services:
6564
postgres:
6665
image: postgres
6766
env:
68-
POSTGRES_USER: postgres
69-
POSTGRES_PASSWORD: postgres
67+
POSTGRES_HOST_AUTH_METHOD: trust
7068
ports:
7169
- 5432:5432
7270
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Clone the codebase
2121
git clone [email protected]:rubyforgood/skillrx.git
2222
```
2323

24+
Create new DB role:
25+
```
26+
psql -d postgres -c 'CREATE ROLE skillrx LOGIN CREATEDB SUPERUSER;'
27+
```
28+
2429
Run the setup script to prepare the DB and assets
2530
```sh
2631
bin/setup

config/database.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ default: &default
1616
adapter: postgresql
1717
encoding: unicode
1818
host: <%= ENV.fetch('DATABASE_HOST') { 'localhost' } %>
19-
user: <%= ENV.fetch('DATABASE_USERNAME') { 'postgres' } %>
20-
password: <%= ENV.fetch('DATABASE_PASSWORD') { 'postgres' } %>
19+
user: <%= ENV.fetch('DATABASE_USERNAME') { 'skillrx' } %>
20+
password: <%= ENV.fetch('DATABASE_PASSWORD') { '' } %>
2121
port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %>
2222
# For details on connection pooling, see Rails configuration guide
2323
# https://guides.rubyonrails.org/configuring.html#database-pooling
@@ -64,9 +64,11 @@ development:
6464
# Do not set this db to the same as development or production.
6565
test:
6666
primary:
67-
url : <%= ENV["DATABASE_URL"] %>
67+
<<: *default
68+
database: skillrx_test
6869
queue:
69-
url : <%= ENV["QUEUE_DATABASE_URL"] %>
70+
<<: *default
71+
database: skillrx_test_queue
7072
migrations_paths: db/queue_migrate
7173

7274
# As with config/credentials.yml, you never want to store sensitive information,
@@ -115,9 +117,9 @@ staging:
115117
migrations_paths: db/cache_migrate
116118
queue:
117119
<<: *default
118-
url: <%= ENV['HEROKU_POSTGRESQL_QUEUE_URL'] || ENV['DATABASE_URL'] %>
120+
url: <%= ENV['HEROKU_POSTGRESQL_QUEUE_URL'] || ENV['QUEUE_DATABASE_URL'] %>
119121
migrations_paths: db/queue_migrate
120122
cable:
121123
<<: *default
122-
url: <%= ENV['HEROKU_POSTGRESQL_CABLE_URL'] || ENV['DATABASE_URL'] %>
124+
url: <%= ENV['HEROKU_POSTGRESQL_CABLE_URL'] || ENV['CABLE_DATABASE_URL'] %>
123125
migrations_paths: db/cable_migrate

0 commit comments

Comments
 (0)