[Dbix-class] How to use filename with ->deploy

Leandro Hermida softdev at leandrohermida.com
Mon Oct 18 09:46:33 GMT 2010


Hi,

If you already have a SQL DDL file to create your schema why bother
with DBIx::Class's deploy method?  Just do something like

system(''psql -f $sqlfile $dbname'') == 0 or die "Failed, exit code:
", $? >> 8, "\n";

>From what I understand (and use it for) the deploy method is if you
have all your DBIx::Class result class files defined with
relationships and all appropriate column info, e.g.

  __PACKAGE__->add_columns(albumid =>
                            { accessor  => 'album',
                              data_type => 'integer',
                              size      => 16,
                              is_nullable => 0,
                              is_auto_increment => 1,
                              default_value => '',
                            },

it will analyze these file and *automatically* generate the approriate
SQL DDL for the target DBMS (PgSQL, MySQL, Oracle, etc.).  It works
really well and you can have just one "schema definition" for your
project (instead of a SQL DDL file for each DBMS you might deploy to)
and let DBIx::Class (and SQL::Translator) figure out how to properly
map that to the DBMS.

hth,
Leandro

On Mon, Oct 18, 2010 at 11:30 AM, Emmanuel Quevillon <tuco at pasteur.fr> wrote:
> Hi dbix users,
>
> I am trying to create a schema db into Pg using deploy method.
> However, it looks like the method does not use the sql file name passed as
> argument to deploy to create my schema. It looks like it uses the schema
> definition given by my Schema::DBmaint::Result::* modules.
>
> Is there a way to use a sql file to be used to create the db schema?
>
> Thanks in advance.
>
> Regards
>
> PS: Here is the code I use :
>
> $conn->deploy({ add_drop_table => 1,
>                show_warnings  => 10,
>                filename       => $file,
>                trace          => 1,
>                validate       => 1})
>        && $self->fatal("_create_dbschema", "Can't create schema");
> --
> -------------------------
> Emmanuel Quevillon
> Biological Software and Databases Group
> Institut Pasteur
> +33 1 44 38 95 98
> tuco at_ pasteur dot fr
> -------------------------
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



More information about the DBIx-Class mailing list