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