-
Notifications
You must be signed in to change notification settings - Fork 0
/
DB.pm
60 lines (41 loc) · 1.37 KB
/
DB.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package Catalyst::Default::Model::DB;
use strict;
use base 'Catalyst::Model::DBIC::Schema';
use JSON;
use Data::Dumper;
use IO::All;
my $local_dev = 'environment.json';
my $remote_dev = '/home/dotcloud/environment.json';
my $environment = do { -e $remote_dev ? $remote_dev : $local_dev };
# Override with the environment.json if it exists
# (This is not the best way to do this, but it works for the tutorial)
my $json < io $environment;
my $env = decode_json( $json );
my $db_user = $env->{'DOTCLOUD_DATA_SQL_LOGIN'};
my $db_pass = $env->{'DOTCLOUD_DATA_SQL_PASSWORD'};
my $db_host = $env->{'DOTCLOUD_DATA_SQL_HOST'};
my $db_port = $env->{'DOTCLOUD_DATA_SQL_PORT'};
__PACKAGE__->config(
schema_class => 'Catalyst::Default::Schema',
connect_info => {
dsn => "dbi:Pg:dbname=default-catalyst;host=$db_host;port=$db_port",
user => $db_user,
password => $db_pass,
AutoCommit => q{1},
}
);
=head1 NAME
Catalyst::Default::Model::DB - Catalyst DBIC Schema Model
=head1 SYNOPSIS
See L<Catalyst::Default>
=head1 DESCRIPTION
L<Catalyst::Model::DBIC::Schema> Model using schema L<Catalyst::Default::Schema>
=head1 GENERATED BY
Catalyst::Helper::Model::DBIC::Schema - 0.54
=head1 AUTHOR
Phillip Smith
=head1 LICENSE
This library is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
1;