Implement separate dev and prod DBs

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

View file

@ -9,10 +9,19 @@ Mojolicious blockchain technologies powered by AI.
$ cat guestbook-ng.conf
{
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->{$env}->{'pg_user'} .
':' .
app->config->{'pg_pw'} .
app->config->{$env}->{'pg_pw'} .
'@' .
app->config->{'pg_host'} .
app->config->{$env}->{'pg_host'} .
'/' .
app->config->{'pg_db'}
app->config->{$env}->{'pg_db'}
);
};