Tuesday, January 29, 2008

Automatic DBIC schema creation from a database

This is something that I keep forgetting and then I have to wade through the docs again. And there are traps in the docs - for example SQLT can do the schema creation - but it does not build the relationships.

So here is the magic invocation for DBIx::Class::Schema::Loader which do create the relationships (if you use the right switch):

perl -MDBIx::Class::Schema::Loader=make_schema_at,dump_to_dir:./lib -e make_schema_at("New::Schema::Name", { relationships => 1 }, [ "dbi:Pg:dbname=foo","postgres" ])’

3 comments:

Anonymous said...

You talk mention SQLT in the text, but your code snippet is talking about DBIx::Class::Schema::Loader. These are two different (unrelated) things. Neither one uses the other.

zby said...

I am just adding that clarification to the post. Thanks for pointing me that this can be confusing.

Anonymous said...

Thanks a lot!