[Dbix-class] arbitrary table names - best practice?

James Kiser james.kiser at gmail.com
Tue May 13 01:51:00 BST 2008


I have a database that contains a few thousand tables that all share
the same structure.  They are all named as [db].[table][unique
number].  The unique number is basically the primary key to another
table which is used to define the 'relationship'.

Obviously, I don't want to create a class for each table and would
ideally like to have one class that will dynamically use the
appropriate table based on the primary key (unique number) that I
have.  The right answer is to redesign the schema and there are plans
to do this.  However, I need a solution I can work with until those
changes take place.

I have a working solution based off of DBIx::Class::Schema::Loader
using the constraint option.  Is using DBIx::Class::Schema::Loader the
*best way* to handle this situation?  Has anyone else had to implement
something similar?  Are there any other alternatives?

Thanks in advance,
James



More information about the DBIx-Class mailing list