Implement separate dev and prod DBs

This commit is contained in:
swag 2021-12-11 18:48:00 -05:00
parent fab89aa92e
commit 2a2b761d0a
2 changed files with 25 additions and 13 deletions

View File

@ -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

View File

@ -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'}
);
};