Bug 18229 - update_dbix_class_files.pl loads defaults from ~/.my.cnf
Summary: update_dbix_class_files.pl loads defaults from ~/.my.cnf
Status: RESOLVED DUPLICATE of bug 21177
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Galen Charlton
QA Contact: Testopia
URL:
Keywords:
Depends on: 18000
Blocks:
  Show dependency treegraph
 
Reported: 2017-03-08 15:21 UTC by Olli-Antti Kivilahti
Modified: 2018-09-15 18:40 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 18229 - update_dbix_class_files.pl loads defaults from ~/.my.cnf (3.15 KB, patch)
2017-03-08 15:25 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Olli-Antti Kivilahti 2017-03-08 15:21:58 UTC
I am so frustrated having to write those elongated --db_name, --db* parameters.

This patch automatically loads defaults from your ~/.my.cnf so you don't have to copypaste stuff or write ad-hoc bash scripts.
Comment 1 Olli-Antti Kivilahti 2017-03-08 15:25:54 UTC
Created attachment 60918 [details] [review]
Bug 18229 - update_dbix_class_files.pl loads defaults from ~/.my.cnf

A) Put this to your ~/.my.cnf

[client]

host                    = 10.0.3.10
port                    = 3306
user                    = koha_ci
password                = "Mr. senior plays with his junior"
database                = koha_ci

B) Then run update_dbix_class_files.pl

perl misc/devel/update_dbix_class_files.pl --tablename issuingrules

C) Update DBIx::Class files like a boss
Comment 2 Jonathan Druart 2017-03-08 15:49:16 UTC
See:

commit e0b0ae20531736ede2cd1113baf16323cb69b3d9
    bug 8798: (follow-up) pass DB connection params to DBIC schema updater explicitly

    This patch changes update_dbix_class_files.pl so that the connection
    parameters to the reference database must be passed explicitly via
    command-line switches, rather than grabbing them from the current Koha
    context.

    The purpose of this is to intentionally put up a roadblock to reduce
    the chance that a developer (or release manager) accidentally updates
    the schema files to include local testing cruft such as temporary
    tables.
Comment 3 Olli-Antti Kivilahti 2017-03-08 16:21:31 UTC
If you feel like that.

I don't mind forking this feature.
Comment 4 Jonathan Druart 2017-03-08 17:04:26 UTC
Actually I already wrote such a patch, but when I say Galen's patch I did not submit mine.

I think this could be re-discussed.
Comment 5 Julian Maurice 2018-09-13 09:38:59 UTC
(In reply to Jonathan Druart from comment #4)
> Actually I already wrote such a patch, but when I say Galen's patch I did
> not submit mine.
> 
> I think this could be re-discussed.

Hmm.. I also wrote a similar patch (in bug 21177). We are at least 3 developers annoyed enough to have written a patch to change that.
I think the reasoning behind this "roadblock" is not valid. Developers are lazy by definition, and if they are annoyed or frustrated by this they will quickly write a custom script to read $KOHA_CONF (or my.cnf) and call update_dbix_class_files.pl with the correct parameters (like this one: https://gitlab.com/snippets/1753594)
Anyway the real danger is for people that push these modifications (RM and RMaint), and I think they know what they're doing.

Now, about this particular bug, I think reading .my.cnf will not be useful for everyone. I, for instance, have several instances of Koha on the same host, and .my.cnf references my primary koha database. So if I'm working on another instance and forget to set --db_name, the script will update my local schema based on another database.
So reading $KOHA_CONF would be better in my case.
Comment 6 Jonathan Druart 2018-09-15 18:40:50 UTC
I think it makes more sense to read koha-conf.xml, marking as a duplicate of bug 21177. Feel free to reopen if you disagree.

*** This bug has been marked as a duplicate of bug 21177 ***