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 $ cat guestbook-ng.conf
{ {
secrets => ['a_secret_here'], secrets => ['a_secret_here'],
pg_user => 'guestbooker', dev_env => {
pg_pw => 'a_password_here', pg_user => 'guestbooker',
pg_db => 'guestbook', pg_pw => 'a_password_here',
pg_host => 'localhost' 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 ## Testing

View File

@ -15,15 +15,18 @@ plugin 'Config';
# Helpers # Helpers
helper pg => sub { helper pg => sub {
my $env =
app->mode eq 'development' ? 'dev_env' : 'prod_env';
state $pg = Mojo::Pg->new( state $pg = Mojo::Pg->new(
'postgres://' . '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'}
); );
}; };