1 |
use warnings; |
2 |
use strict; |
3 |
|
4 |
package SQLSession::Bootstrap; |
5 |
use base qw(Jifty::Bootstrap); |
6 |
|
7 |
=head1 Bootstrap application data |
8 |
|
9 |
Create initial data |
10 |
|
11 |
=cut |
12 |
|
13 |
sub run { |
14 |
my $self = shift; |
15 |
|
16 |
my $system_user = SQLSession::CurrentUser->superuser( _bootstrap => 1 ); |
17 |
|
18 |
my $db = SQLSession::Model::Database->new(current_user => $system_user); |
19 |
$db->create( |
20 |
name => 'test', |
21 |
dsn => 'DBI:Pg:dbname=test', |
22 |
); |
23 |
|
24 |
my $q = SQLSession::Model::Query->new(current_user => $system_user); |
25 |
$q->create( |
26 |
name => 'test query', |
27 |
sql_query => 'select * from a;', |
28 |
on_database => $db, |
29 |
); |
30 |
|
31 |
$db->create( |
32 |
name => 'Pagila sample database', |
33 |
dsn => 'DBI:Pg:dbname=pagila', |
34 |
); |
35 |
|
36 |
$q->create( |
37 |
name => 'All films', |
38 |
sql_query => 'select * from film', |
39 |
on_database => $db, |
40 |
); |
41 |
|
42 |
} |
43 |
|
44 |
1; |