Created
December 13, 2009 01:29
-
-
Save dhoss/255197 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SmallBoard::Script::Deploy; | |
use Moose; | |
use MooseX::Types::Moose qw/Str/; | |
use namespace::autoclean; | |
use SmallBoard::Schema; | |
with 'Catalyst::ScriptRole'; | |
has dsn => ( | |
traits => [qw(Getopt)], | |
isa => Str, | |
is => 'ro', | |
required => 1, | |
documentation => "dsn for your database" | |
); | |
has user => ( | |
traits => [qw(Getopt)], | |
isa => Str, | |
is => 'ro', | |
required => 1, | |
documentation => "username for your database", | |
); | |
has password => ( | |
traits => [qw(Getopt)], | |
isa => Str, | |
is => 'ro', | |
documentation => "password for your database", | |
); | |
has schema => ( | |
traits => [qw(NoGetopt)], | |
isa => 'SmallBoard::Schema', | |
is => "ro", | |
default => sub { my $self = shift; SmallBoard::Schema->connect($self->dsn, $self->user, $self->password); }, | |
); | |
sub run { | |
my ($self) = @_; | |
$self->_getopt_full_usage if !$self->ARGV->[0]; | |
$self->schema->deploy or die "Can't deploy: $!"; | |
} | |
__PACKAGE__->meta->make_immutable; | |
1; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
## called like: perl script/smallboard_deploy.pl --user urmom --password urmom --dsn dbi:SQLite:smallboard.db | |
use Catalyst::ScriptRunner; | |
Catalyst::ScriptRunner->run('SmallBoard', 'Deploy'); | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment