line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::RoutesAuthDBI::Schema; |
2
|
2
|
|
|
2
|
|
88746
|
use Mojo::Base 'Mojolicious::Controller'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
12
|
|
3
|
2
|
|
|
2
|
|
1568
|
use DBIx::Mojo::Template; |
|
2
|
|
|
|
|
21968
|
|
|
2
|
|
|
|
|
19
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $defaults = {# copy to pod! |
6
|
|
|
|
|
|
|
schema => "public", |
7
|
|
|
|
|
|
|
sequence => '"public"."id"', |
8
|
|
|
|
|
|
|
tables => { # no quotes! one schema! |
9
|
|
|
|
|
|
|
routes => 'routes', |
10
|
|
|
|
|
|
|
refs=>'refs', |
11
|
|
|
|
|
|
|
logins => 'logins', |
12
|
|
|
|
|
|
|
profiles => 'profiles', |
13
|
|
|
|
|
|
|
roles =>'roles', |
14
|
|
|
|
|
|
|
actions => 'actions', |
15
|
|
|
|
|
|
|
controllers => 'controllers', |
16
|
|
|
|
|
|
|
namespaces => 'namespaces', |
17
|
|
|
|
|
|
|
oauth_sites => 'oauth.sites', |
18
|
|
|
|
|
|
|
oauth_users => 'oauth.users', |
19
|
|
|
|
|
|
|
guests => 'guests', |
20
|
|
|
|
|
|
|
logs=>'logs', |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
my $dict = DBIx::Mojo::Template->new(__PACKAGE__, vars=>$defaults, mt=>{tag_start=>'{%', tag_end=>'%}'}); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=pod |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=encoding utf8 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 Mojolicious::Plugin::RoutesAuthDBI::Schema |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! ! |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Mojolicious::Plugin::RoutesAuthDBI::Schema - DB schema (PostgreSQL). |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DB DESIGN DIAGRAM |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
See L |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DB design |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 Default variables for SQL templates |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
schema => "public", |
48
|
|
|
|
|
|
|
sequence => '"public"."id"', |
49
|
|
|
|
|
|
|
tables => { # no quotes! one schema! |
50
|
|
|
|
|
|
|
routes => 'routes', |
51
|
|
|
|
|
|
|
refs=>'refs', |
52
|
|
|
|
|
|
|
logins => 'logins', |
53
|
|
|
|
|
|
|
profiles => 'profiles', |
54
|
|
|
|
|
|
|
roles =>'roles', |
55
|
|
|
|
|
|
|
actions => 'actions', |
56
|
|
|
|
|
|
|
controllers => 'controllers', |
57
|
|
|
|
|
|
|
namespaces => 'namespaces', |
58
|
|
|
|
|
|
|
oauth_sites => 'oauth.sites', |
59
|
|
|
|
|
|
|
oauth_users => 'oauth.users', |
60
|
|
|
|
|
|
|
guests => 'guests', |
61
|
|
|
|
|
|
|
logs=>'logs', |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _vars { |
70
|
2
|
|
|
2
|
|
6
|
my $c = shift; |
71
|
2
|
|
|
|
|
6
|
my $vars = {}; |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
8
|
for my $var (keys %$defaults) { |
74
|
|
|
|
|
|
|
|
75
|
6
|
100
|
|
|
|
23
|
if (ref $defaults->{$var} eq 'HASH') { |
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
13
|
for (keys %{$defaults->{$var}}) { |
|
2
|
|
|
|
|
16
|
|
78
|
24
|
|
66
|
|
|
67
|
my $val = $c->stash($_) || $c->param($_) || $defaults->{$var}{$_}; |
79
|
24
|
50
|
|
|
|
1746
|
$vars->{$var}{$_} = $val |
80
|
|
|
|
|
|
|
unless $val =~ m'undef|none'; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} else { |
83
|
4
|
|
33
|
|
|
17
|
my $val = $c->stash($var) || $c->param($var) || $defaults->{$var}; |
84
|
4
|
50
|
|
|
|
1961
|
$vars->{$var} = $val |
85
|
|
|
|
|
|
|
unless $val =~ m'undef|none'; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
} |
89
|
2
|
|
|
|
|
10
|
$vars; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub schema { |
93
|
1
|
|
|
1
|
0
|
347
|
my $c = shift; |
94
|
1
|
|
|
|
|
3
|
my $vars = $c->_vars; |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
7
|
$c->app->log->debug($c->dumper($vars)); |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
264
|
my $text = $dict->{'schema'}->render(%$vars); |
99
|
|
|
|
|
|
|
$text .= "\n\n".$dict->{'sequence'}->render(%$vars) |
100
|
1
|
50
|
|
|
|
2448
|
if $vars->{sequence}; |
101
|
|
|
|
|
|
|
$text .= "\n\n".$dict->{$_}->render(%$vars) |
102
|
1
|
|
|
|
|
1669
|
for grep $vars->{tables}{$_}, qw(routes namespaces controllers actions profiles logins roles refs oauth_sites oauth_users guests logs); |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
26103
|
$c->render(format=>'txt', text => $text); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub schema_drop { |
109
|
1
|
|
|
1
|
0
|
360
|
my $c = shift; |
110
|
1
|
|
|
|
|
3
|
my $vars = $c->_vars; |
111
|
|
|
|
|
|
|
#~ $schema = qq{"$schema".} if $schema; |
112
|
1
|
|
|
|
|
13
|
$c->render(format=>'txt', text => $dict->{'drop'}->render(%$vars)); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub schema_flush { |
117
|
0
|
|
|
0
|
0
|
|
my $c = shift; |
118
|
0
|
|
|
|
|
|
my $vars = $c->_vars; |
119
|
0
|
|
|
|
|
|
$c->render(format=>'txt', text => $dict->{'flush'}->render(%$vars)); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__DATA__ |