frioux / DBIx-Class-DeploymentHandler

https://metacpan.org/pod/DBIx::Class::DeploymentHandler
21 stars 26 forks source link

No way to globally pass schema loader options for 'schema_from_schema_loader' #36

Closed mrenvoize closed 9 years ago

mrenvoize commented 9 years ago

I came across this one whilst attempting to use db schema's (as in what the db vendor means) with deployment handler.

In the DBIC Connection call I have an 'on_connect_do => [ SET search_path TO my_schema ] setup for my postgres connection. This works well for the txn_do calls as we use the dbic handle so our search path is always set.. however when we move onto the perl scripts the SET is not run adn therefore the dbic schema that is 'dumped' is not relating the the right database schema (In schema::loader there is a different arguament for this 'db_schema => my_schema').

I'd like to be able to set this for all my scripts rather than specify it per perl script.. much like 'sql_translator_args' can be.

mrenvoize commented 9 years ago

This relates very closely to #27 as in that example he hard codes a schema into the sl_opts argument.

In my case, my schema name isn't so clear cut so I wanted to pass in a variable instead, which ends up rather complicated.

mrenvoize commented 9 years ago

Wondering if you'de got a chance to look at this at all? I got completely lost in the code in my attempts :(

frioux commented 9 years ago

Sorry I have not looked into this, will maybe look this week, I keep missing it in my weekly OSS time!

frioux commented 9 years ago

Ok this is what I think I'm going to do; I'm going to make a little "sugar generator" that lets you define a new schema_from_schema_loader for your own project. The idea is that in general most people will have just one and can name it something nice and short like schema, but later when you find that you need to change it based on a new schema in the db you can make a schema_2 and the old migrations will continue to work as they did before. I expect to have this done before the 10th.

frioux commented 9 years ago

Ok, I documented a pattern because all the ideas I had to generate sugar were just as much work. I hope this helps; if it doesn't, let me know.

https://metacpan.org/pod/release/FREW/DBIx-Class-DeploymentHandler-0.002217/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/ScriptHelpers.pm#CUSTOM-SCRIPT-HELPERS

mrenvoize commented 9 years ago

Many thanks frioux, I'll have a quick read this morning.. been away for a week so my apologies for not getting back to your comments sooner.

mrenvoize commented 8 years ago

Works a charm, thanks for the clear documentation :)

frioux commented 8 years ago

Great!

sent from a rotary phone, pardon my brevity On Oct 10, 2015 3:56 AM, "Martin Renvoize" notifications@github.com wrote:

Works a charm, thanks for the clear documentation :)

— Reply to this email directly or view it on GitHub https://github.com/frioux/DBIx-Class-DeploymentHandler/issues/36#issuecomment-147066941 .