Created
May 17, 2011 21:47
-
-
Save reyjrar/977478 to your computer and use it in GitHub Desktop.
Create the PacketFence ORM Classes from the Database
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 | |
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