|
11 | 11 | # set all String properties to have a default length of 255
|
12 | 12 | DataMapper::Property::String.length(255)
|
13 | 13 |
|
| 14 | +USER = ENV['POSTGRES_USER'] || 'junethack' |
| 15 | +PASSWORD = ENV['POSTGRES_PASSWORD'] || 'test' |
| 16 | +HOST = ENV['POSTGRES_HOST'] || 'localhost' |
| 17 | + |
14 | 18 | configure :production do
|
15 | 19 | puts "Configuring production database"
|
| 20 | + DATABASE = ENV['POSTGRES_DATABASE'] || 'junethack_production' |
16 | 21 | # for debugging: print all generated SQL statemtens
|
17 | 22 | #DataMapper::Logger.new("logs/db.log", :debug)
|
18 |
| - DataMapper.setup(:default, 'postgres://localhost/junethack') |
| 23 | + DataMapper.setup(:default, "postgres://#{USER}:#{PASSWORD}@#{HOST}/#{DATABASE}") |
19 | 24 | end
|
20 | 25 |
|
21 | 26 | configure :development do
|
22 | 27 | puts "Configuring development database"
|
| 28 | + DATABASE = ENV['POSTGRES_DATABASE'] || 'junethack_developmnet' |
23 | 29 | # for debugging: print all generated SQL statemtens
|
24 | 30 | DataMapper::Logger.new("logs/dev_db.log", :debug)
|
25 |
| - DataMapper.setup(:default, 'postgres://localhost/junethack') |
| 31 | + DataMapper.setup(:default, "postgres://#{USER}:#{PASSWORD}@#{HOST}/#{DATABASE}") |
26 | 32 | end
|
27 | 33 |
|
28 | 34 | configure :test do
|
29 | 35 | puts "Configuring test database"
|
| 36 | + DATABASE = ENV['POSTGRES_DATABASE'] || 'junethack_text' |
30 | 37 | DataMapper::Logger.new("logs/test_db.log", :debug)
|
31 |
| - DataMapper.setup(:default, "postgres://#{user}:#{password}@localhost/junethack_test") |
| 38 | + DataMapper.setup(:default, "postgres://#{USER}:#{PASSWORD}@#{HOST}/#{DATABASE}") |
32 | 39 |
|
33 | 40 | # suppress migration output.
|
34 | 41 | # it would be written at every run as we use a in-memory db
|
|
0 commit comments