FAQ
Dear All

Please forgive me, may i must ask this question on DBIX maillist.

I'd like to use "script/???_create.pl" helper script to create
model from a PostgreSql database.
But my tables are not in the default Postgre tablespace (public).

Is this helper script capable to automatically create model for
the non-default tablespace?

If i run the script the standard way:

script/pcm_create.pl model DB DBIC::Schema Pcm::Schema create=static
components=TimeStamp,EncodedColumn 'dbi:Pg:dbname=pcmv2;host=xxx.xx'
'pcmuser' 'xxx' '{ AutoCommit => 1 }'

the script dumps schema without errors:

...
Dumping manual schema for Pcm::Schema to directory
/home/csabi/Dev/Pcm/script/../lib ...
Schema dump completed.
created "/home/csabi/Dev/Pcm/script/../lib/Pcm/Model/DB.pm"
created "/home/csabi/Dev/Pcm/script/../t/model_DB.t"

But when starting the application it says:

******************************* WARNING
***************************************
* No sources found (did you forget to define your
tables?) *
*
*
* To turn off this warning, set the CMDS_NO_SOURCES environment
variable. *
*******************************************************************************

which is correct, because there is no tables in the default "public" pg
schema.
My tables are in the manually created "pcmbiz" schema.

Thank You in advance!

--
Het?nyi Csaba

Search Discussions

  • Tamás Eisenberger at Oct 20, 2010 at 3:38 pm
    Hy!

    I use DBIC's on_connect_do parameter to switch to the right pg schema like
    this in the config:
    <Model::Yourschema>
    <connect_info>
    dsn dbi:Pg:host=localhost;dbname=yourdb
    user youruser
    password yourpw
    pg_enable_utf8 1
    on_connect_do SET search_path TO yourschema
    </connect_info>
    </Model::Yourschema>

    2010/10/20 Hetényi Csaba <csabiwork@tata.hu>
    Dear All

    Please forgive me, may i must ask this question on DBIX maillist.

    I'd like to use "script/???_create.pl" helper script to create
    model from a PostgreSql database.
    But my tables are not in the default Postgre tablespace (public).

    Is this helper script capable to automatically create model for
    the non-default tablespace?

    If i run the script the standard way:

    script/pcm_create.pl model DB DBIC::Schema Pcm::Schema create=static
    components=TimeStamp,EncodedColumn 'dbi:Pg:dbname=pcmv2;host=xxx.xx'
    'pcmuser' 'xxx' '{ AutoCommit => 1 }'

    the script dumps schema without errors:

    ...
    Dumping manual schema for Pcm::Schema to directory
    /home/csabi/Dev/Pcm/script/../lib ...
    Schema dump completed.
    created "/home/csabi/Dev/Pcm/script/../lib/Pcm/Model/DB.pm"
    created "/home/csabi/Dev/Pcm/script/../t/model_DB.t"

    But when starting the application it says:

    ******************************* WARNING
    ***************************************
    * No sources found (did you forget to define your tables?)
    *
    *
    *
    * To turn off this warning, set the CMDS_NO_SOURCES environment variable.
    *

    *******************************************************************************

    which is correct, because there is no tables in the default "public" pg
    schema.
    My tables are in the manually created "pcmbiz" schema.

    Thank You in advance!

    --
    Hetényi Csaba



    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101020/37f062c6/attachment.htm
  • Benjamin Martin at Oct 20, 2010 at 3:44 pm

    On 20/10/10 15:22, Het?nyi Csaba wrote:
    Is this helper script capable to automatically create model for
    the non-default tablespace?
    I believe this is known issue with ::Schema::Loader.

    http://search.cpan.org/~ribasushi/DBIx-Class-Schema-Loader-0.07002/lib/DBIx/Class/Schema/Loader.pm#KNOWN_ISSUES

    You can sort of get around it by specifiy 'db_schema' (I think you can
    get it into the command line script args)

    I think it works with Postgres but with Oracle it did not seem to work..
    I think, regardless, you will have to manually add cross schema
    relationships.

    Its not hard to roll your own script to build and manage your ::Result::
    files... just take a peek at the ::Schema::Loader cpan docs.
  • Benjamin Hitz at Oct 20, 2010 at 4:29 pm
    I believe the repo (SVN?) version of DBIx::Class::Schema::Loader::Oracle has a fix for this.
    Sorry I don't have the details right now, I have put down the dbic/catalyst pipe for a while.

    Ben
    On Oct 20, 2010, at 8:44 AM, Benjamin Martin wrote:
    On 20/10/10 15:22, Het?nyi Csaba wrote:
    Is this helper script capable to automatically create model for
    the non-default tablespace?
    I believe this is known issue with ::Schema::Loader.

    http://search.cpan.org/~ribasushi/DBIx-Class-Schema-Loader-0.07002/lib/DBIx/Class/Schema/Loader.pm#KNOWN_ISSUES

    You can sort of get around it by specifiy 'db_schema' (I think you can get it into the command line script args)

    I think it works with Postgres but with Oracle it did not seem to work.. I think, regardless, you will have to manually add cross schema relationships.

    Its not hard to roll your own script to build and manage your ::Result:: files... just take a peek at the ::Schema::Loader cpan docs.

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    --
    Ben Hitz
    Senior Scientific Programmer ** Saccharomyces Genome Database ** GO Consortium
    Stanford University ** hitz@genome.stanford.edu
  • Peter Shangov at Oct 20, 2010 at 4:02 pm
    Hi,

    When generating models your create.pl script uses internally
    DBIx::Class::Schema::Loader and you can pass to it most of the options that you
    can pass to DBIx::Class::Schema::Loader's dbicdump utility. You will probably
    need to use 'db_schema', which lets you specify the schema for which to generate
    table classes. You may also look into 'qualify_objects', which prepends the
    value of 'db_schema' to table names and relationships (this may be useful if you
    are working with multiple schemas simultaneously). All of the above options are
    documented in the docs for DBIx::Class::Schema::Loader::Base.

    Regards,


    ----- Original Message ----
    From: Het?nyi Csaba <csabiwork@tata.hu>
    To: The elegant MVC web framework <catalyst@lists.scsys.co.uk>
    Sent: Wed, 20 October, 2010 17:22:15
    Subject: [Catalyst] Postgresql database with non default -public- schema

    Dear All

    Please forgive me, may i must ask this question on DBIX maillist.

    I'd like to use "script/???_create.pl" helper script to create
    model from a PostgreSql database.
    But my tables are not in the default Postgre tablespace (public).

    Is this helper script capable to automatically create model for
    the non-default tablespace?

    If i run the script the standard way:

    script/pcm_create.pl model DB DBIC::Schema Pcm::Schema create=static
    components=TimeStamp,EncodedColumn 'dbi:Pg:dbname=pcmv2;host=xxx.xx' 'pcmuser'
    'xxx' '{ AutoCommit => 1 }'

    the script dumps schema without errors:

    ...
    Dumping manual schema for Pcm::Schema to directory
    /home/csabi/Dev/Pcm/script/../lib ...
    Schema dump completed.
    created "/home/csabi/Dev/Pcm/script/../lib/Pcm/Model/DB.pm"
    created "/home/csabi/Dev/Pcm/script/../t/model_DB.t"

    But when starting the application it says:

    ******************************* WARNING
    ***************************************
    * No sources found (did you forget to define your tables?)
    *
    *
    *
    * To turn off this warning, set the CMDS_NO_SOURCES environment variable.
    *
    *******************************************************************************
    which is correct, because there is no tables in the default "public" pg
    schema.
    My tables are in the manually created "pcmbiz" schema.

    Thank You in advance!

    -- Het?nyi Csaba



    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Hetényi Csaba at Oct 20, 2010 at 5:40 pm
    Thank You All for help

    The "db_schema" option works:

    script/pcm_create.pl model DB DBIC::Schema Pcm::Schema create=static
    components=TimeStamp,EncodedColumn db_schema=pcmbiz 'dbi:Pg:.....

    I hope "at some point in the future" the schema loader will support
    multiple db schemas!

    The automatic schema generation is a very convenient feature -especially
    in developing phase, when table structures often change. :)

    Thank You!
  • Benjamin Martin at Oct 21, 2010 at 7:47 am

    On 20/10/10 18:40, Het?nyi Csaba wrote:
    The automatic schema generation is a very convenient feature -especially
    in developing phase, when table structures often change.
    I hear you!... I have the exact same issue.

    So far writing my own script that harnesses the power of
    DBIX::Class::Schema::Loader to run over each schema in my DB seems to be
    working out well... althou, due to some horrific column naming my dbic
    objects have a some ugly accessor names... I feel I 'might' start
    manually managing my ::Result:: files :(
  • Eden Cardim at Oct 23, 2010 at 3:05 pm
    "Het?nyi" == Het?nyi Csaba writes:
    Het?nyi> Thank You All for help The "db_schema" option works:

    Het?nyi> script/pcm_create.pl model DB DBIC::Schema Pcm::Schema
    Het?nyi> create=static components=TimeStamp,EncodedColumn
    Het?nyi> db_schema=pcmbiz 'dbi:Pg:.....

    Het?nyi> I hope "at some point in the future" the schema loader will
    Het?nyi> support multiple db schemas!

    Het?nyi> The automatic schema generation is a very convenient
    Het?nyi> feature -especially in developing phase, when table
    Het?nyi> structures often change. :)

    Have a look at DBIx::Class::Schema::Versioned, it's designed
    specifically for managing changes in your schema.

    --
    Eden Cardim Need help with your Catalyst or DBIx::Class project?
    Code Monkey http://www.shadowcat.co.uk/catalyst/
    Shadowcat Systems Ltd. Want a managed development or deployment platform?
    http://blog.edencardim.com/ http://www.shadowcat.co.uk/servers/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedOct 20, '10 at 2:22p
activeOct 23, '10 at 3:05p
posts8
users6
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase