Skip to content

Instantly share code, notes, and snippets.

@dhoss
Created December 13, 2009 01:29
Show Gist options
  • Save dhoss/255197 to your computer and use it in GitHub Desktop.
Save dhoss/255197 to your computer and use it in GitHub Desktop.
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;
#!/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