Implement separate dev and prod DBs
This commit is contained in:
parent
fab89aa92e
commit
2a2b761d0a
19
README.md
19
README.md
|
@ -8,11 +8,20 @@ Mojolicious blockchain technologies powered by AI.
|
|||
|
||||
$ cat guestbook-ng.conf
|
||||
{
|
||||
secrets => ['a_secret_here'],
|
||||
pg_user => 'guestbooker',
|
||||
pg_pw => 'a_password_here',
|
||||
pg_db => 'guestbook',
|
||||
pg_host => 'localhost'
|
||||
secrets => ['a_secret_here'],
|
||||
dev_env => {
|
||||
pg_user => 'guestbooker',
|
||||
pg_pw => 'a_password_here',
|
||||
pg_db => 'guestbook',
|
||||
pg_host => 'localhost'
|
||||
},
|
||||
prod_env => {
|
||||
pg_user => 'guestbooker',
|
||||
pg_pw => 'prod_password_here',
|
||||
pg_db => 'guestbook',
|
||||
pg_host => 'prod.db.com'
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
## Testing
|
||||
|
|
|
@ -15,15 +15,18 @@ plugin 'Config';
|
|||
|
||||
# Helpers
|
||||
helper pg => sub {
|
||||
my $env =
|
||||
app->mode eq 'development' ? 'dev_env' : 'prod_env';
|
||||
|
||||
state $pg = Mojo::Pg->new(
|
||||
'postgres://' .
|
||||
app->config->{'pg_user'} .
|
||||
':' .
|
||||
app->config->{'pg_pw'} .
|
||||
'@' .
|
||||
app->config->{'pg_host'} .
|
||||
'/' .
|
||||
app->config->{'pg_db'}
|
||||
'postgres://' .
|
||||
app->config->{$env}->{'pg_user'} .
|
||||
':' .
|
||||
app->config->{$env}->{'pg_pw'} .
|
||||
'@' .
|
||||
app->config->{$env}->{'pg_host'} .
|
||||
'/' .
|
||||
app->config->{$env}->{'pg_db'}
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue