[Catalyst] Limit Catalyst::Helper::Model::DBIC::Schema to a singletable ...

Octavian Râşniţă orasnita at gmail.com
Fri Dec 25 15:05:13 GMT 2009


From: "Kiffin Gish" <kiffin.gish at planet.nl>
> Normally myapp_create.pl is run with the whole database given on the
> command line, e.g.
>
> script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \
>    create=static dbi:SQLite:myapp.db
>
> Can I restrict this to a single table or tables only? For example, I
> have an existing application and I add a new table I don't want to
> recreate Schema/Results with a bunch of .new files and have to delete
> them after-wards.
>
> -- 
> Kiffin Gish <Kiffin.Gish at planet.nl>


Don't know if it has that option, but the script below might help you:


use warnings;
use strict;
use FindBin qw/$Bin/;
use DBIx::Class::Schema::Loader qw/ make_schema_at /;

my %options;
if (@ARGV) {
my $table = shift @ARGV;
%options = (
constraint => "^$table\$",
#exclude => "^$table\$",
components => [@ARGV]);
}

make_schema_at("MyApp::Schema",
{
%options,
debug => 1,
relationships => 1,
use_namespaces => 1,
dump_directory => "$Bin/../lib" ,
},
["dbi:mysql:database=mydb",
"user","password"]);

Octavian
 




More information about the Catalyst mailing list