Skip to content

Instantly share code, notes, and snippets.

@reyjrar
Created May 17, 2011 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reyjrar/977478 to your computer and use it in GitHub Desktop.
Save reyjrar/977478 to your computer and use it in GitHub Desktop.
Create the PacketFence ORM Classes from the Database
#!/usr/bin/env perl
use strict;
use warnings;
use Config::IniFiles;
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
if( !-d './lib') {
die "must be run in the root dir of PacketFence!\n";
}
my $CFG = Config::IniFiles->new( -file => 'conf/pf.conf' ) or die "unable to source config file!\n";
make_schema_at(
'pf::schema',
{
dump_directory=> './lib',
exclude => qr/(^pg_)|(^v_admin)|(^v_history)/,
moniker_map => sub {
my $table = shift;
my %map = (
# Table => 'ClassName',
);
return $map{$table} if exists $map{$table};
my $class = $table;
$class =~ s/\_/::/g;
return $class;
},
skip_relationships => 1,
components => [qw(InflateColumn::DateTime PK::Auto)],
},
[ 'dbi:mysql:database=pf', 'pf', $CFG->val( 'database', 'pass' ) ]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment