Stuff…

I know I will forget.

Stuff… header image 2

Unable to load schema – chosen moniker/class naming style results in moniker clashes

July 22nd, 2010 · No Comments

Was trying to generate the Perl module DBIx::Class schema files from a database using DBIx::Class::Schema::Loader.  Using the example on the CPAN page for DBIx::Class::Schema::Loader the following error came up.

Unable to load schema – chosen moniker/class naming style results in moniker clashes. Either change the naming style, or supply an explicit moniker_map: tables ‘dm_pp_hn’, ‘dm_pp_hns’ reduced to the same source moniker ‘DmPpHn’

The table names were obviously very similar and causing a problem when generating the schema.  Additional information could be found in: DBIx::Class::Schema::Loader::Base

http://search.cpan.org/~rkitover/DBIx-Class-Schema-Loader-0.07000/lib/DBIx/Class/Schema/Loader/Base.pm#moniker_map

Basically changed the code from:

#!/usr/bin/perl

use DBIx::Class::Schema::Loader qw/ make_schema_at /;
make_schema_at(
‘dbname::Schema’,
{ debug => 1,
dump_directory => ‘./Schema’,
},
[ 'dbi:mysql:dbname=dbname', 'user', 'pass',
#         { loader_class => 'MyLoader' } # optionally
],
);

To:

#!/usr/bin/perl

use DBIx::Class::Schema::Loader qw/ make_schema_at /;
make_schema_at(
‘dbname::Schema’,
{ debug => 1,
dump_directory => ‘./Schema’,
moniker_map => { ‘dm_pp_hn’ => ‘DmPpHn’,
‘dm_pp_hns’ => ‘DmPpHnS’,
},
},
[ 'dbi:mysql:dbname=dbname', 'user', 'pass',
#         { loader_class => 'MyLoader' } # optionally
],
);

And the schema was dumped successfully.

Tags: Coding

0 responses so far ↓

  • There are no comments yet...

Leave a Comment