Commit | Line | Data |
1efc6c6b |
1 | package Catalyst::Script::Deploy; |
2 | |
3 | use Moose; |
4 | use namespace::autoclean; |
5 | |
6 | with 'MooseX::Getopt'; |
7 | use Config::General; |
8 | use FindBin; |
9 | use lib "$FindBin::Bin/../lib"; |
10 | |
11 | has _app => ( |
12 | reader => 'app', |
13 | init_arg => 'app', |
14 | traits => [qw(NoGetopt)], |
15 | isa => 'Str', |
16 | is => 'ro', |
17 | ); |
18 | |
19 | has conf => ( |
20 | is => 'ro', |
21 | isa => 'Str', |
22 | traits => [qw(Getopt)], |
23 | cmd_alias => 'c', |
24 | ); |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | sub usage { |
31 | |
32 | print "usage: perl script/boyosplace_deploy_schema.pl boyosplace.conf\n"; |
33 | exit; |
34 | |
35 | } |
36 | |
37 | sub run { |
38 | my ($self) = shift; |
39 | |
40 | $self->usage if $self->help; |
41 | |
42 | my $app = $self->app; |
43 | Class::MOP::load_class($app); |
44 | Class::MOP::load_class("$app::Schema"); |
45 | |
46 | my %hash = $conf->getall; |
47 | |
48 | my $schema = $app::Schema->connect( |
49 | $hash{"Model::$schema_name"}{connect_info}[0], |
50 | $hash{"Model::$schema_name"}{connect_info}[1], |
51 | $hash{"Model::$schema_name"}{connect_info}[2] |
52 | ); |
53 | $schema->deploy( { add_drop_tables => 1 } ); |
54 | |
55 | |
56 | } |
57 | |
58 | no Moose; |
59 | __PACKAGE__->meta->make_immutable; |
60 | |
61 | 1; |
62 | |