Remove unused TestApp
[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';
4e45780e 7use MooseX::Types::Moose qw/Str/;
1efc6c6b 8use Config::General;
9use FindBin;
10use lib "$FindBin::Bin/../lib";
11
410d96eb 12#extends qw(MooseX::App::Cmd);
13
14
1efc6c6b 15has _app => (
16 reader => 'app',
17 init_arg => 'app',
18 traits => [qw(NoGetopt)],
73e4f0f1 19 isa => Str,
1efc6c6b 20 is => 'ro',
21);
22
23has conf => (
24 is => 'ro',
73e4f0f1 25 isa => Str,
1efc6c6b 26 traits => [qw(Getopt)],
27 cmd_alias => 'c',
d6e8e664 28 documentation => qq{ specify a configuration file to read from }
1efc6c6b 29);
30
1efc6c6b 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
1efc6c6b 59__PACKAGE__->meta->make_immutable;
60
611;
62