[Catalyst] create=static

Brandon Black blblack at gmail.com
Tue Jan 2 14:31:07 GMT 2007


On 1/2/07, Octavian Rasnita <orasnita at gmail.com> wrote:
> Hi,
>
> I have tried the following:
>
> perl script/tranzactiibursiere_create.pl model Db DBIC::Schema Db
> create=static dbi:mysql:database=intranet root
>
> First, I have seen that this command creates all the class files for each
> table, but some of them are not complete. For example, even though I have
> used in some tables columns defined with:
>
> references table_name(id)
>
> The program doesn't add the line
> __PACKAGE__->belongs_to(...)
>
> And the lines
> __PACKAGE__->has_many(...)
> are not added automaticly either.
>
> It is not a big problem to insert them manually, but sometimes I need to
> modify the table definitions, and in that case I need to create them again
> manually.
>

Are you absolutely sure that your foreign keys are really working in
MySQL?  Are you using InnoDB?  Did you specify them on a separate line
like "FOREIGN KEY (foo) REFERENCES bar (baz)" ?  Do they exist when
you look at the output of "SHOW CREATE TABLE table_name"?

The Loader will only see them if they really exist in the database,
and it is surprisingly easy in MySQL-land to be fooled into thinking
you have foreign key relationships, when in fact you don't.  (see
http://bugs.mysql.com/bug.php?id=17943 and
http://bugs.mysql.com/bug.php?id=4919 that I've recently added rants
to, because I keep hearing this same problem over and over from
Loader/MySQL users )

> How do you do this to be more easy?
>

Don't use MySQL would be a good start :)

> I have also tried using the parameter create=dynamic but I have seen that it
> is creating only the model and not the table classes also.
> What is this option exactly doing, and how should it be used, or why it
> doesn't create the table classes?
>

create=dynamic creates a minimal model and schema class, but defers
the creation of the table classes until runtime, in memory.  This
ensures that every change is taken into account every time you start
your application.  It is not recommended to use this in production,
and causes a lot of startup performance overhead.

-- Brandon



More information about the Catalyst mailing list