Browse files

add deploy script, and scheam classes

  • Loading branch information...
1 parent 14c93ca commit e0eab8d2e1a626462dfa2a058ac11baa6f8203fb franck cuny committed Apr 22, 2009
Showing with 45 additions and 29 deletions.
  1. +22 −0 bin/deploy_mymodel.pl
  2. +2 −29 lib/MyModel.pm
  3. +10 −0 lib/MyModel/Entry.pm
  4. +11 −0 lib/MyModel/Feed.pm
View
22 bin/deploy_mymodel.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl -w
+use strict;
+use feature ':5.10';
+use Getopt::Long;
+use lib('lib');
+use MyModel;
+
+GetOptions(
+ 'dsn=s' => \my $dsn,
+ 'user=s' => \my $user,
+ 'passwd=s' => \my $passwd
+) or die usage();
+
+my $schema = MyModel->connect($dsn, $user, $passwd);
+say 'deploying schema ...';
+$schema->deploy;
+
+say 'done';
+
+sub usage {
+ say 'usage: deploy_mymodel.pl --dsn $dsn --user $user --passwd $passwd';
+}
View
31 lib/MyModel.pm
@@ -1,33 +1,6 @@
package MyModel;
+use base qw/DBIx::Class::Schema/;
-use strict;
-use warnings;
-our $VERSION = '0.01';
+__PACKAGE__->load_classes();
1;
-__END__
-
-=head1 NAME
-
-MyModel -
-
-=head1 SYNOPSIS
-
- use MyModel;
-
-=head1 DESCRIPTION
-
-MyModel is
-
-=head1 AUTHOR
-
-franck cuny E<lt>franck.cuny@rtgi.frE<gt>
-
-=head1 SEE ALSO
-
-=head1 LICENSE
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
View
10 lib/MyModel/Entry.pm
@@ -0,0 +1,10 @@
+package MyModel::Entry;
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components(qw/Core/);
+__PACKAGE__->table('entry');
+__PACKAGE__->add_columns(qw/ entryid permalink feedid/);
+__PACKAGE__->set_primary_key('entryid');
+__PACKAGE__->belongs_to(feed => 'MyModel::Feed', 'feedid');
+
+1;
View
11 lib/MyModel/Feed.pm
@@ -0,0 +1,11 @@
+package MyModel::Feed;
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components(qw/Core/);
+__PACKAGE__->table('feed');
+__PACKAGE__->add_columns(qw/ feedid url /);
+__PACKAGE__->set_primary_key('feedid');
+__PACKAGE__->has_many(entries => 'MyModel::Feed', 'feedid');
+
+1;
+

0 comments on commit e0eab8d

Please sign in to comment.