mbucc / shmig

Database migration tool written in BASH.
BSD 3-Clause "New" or "Revised" License
458 stars 49 forks source link

Allow `-a` argument to _add to_ previously-set `$ARGS`, rather than overwrite #45

Closed kael-shipman closed 5 years ago

kael-shipman commented 6 years ago

$ARGS is special in that it contains command-line flags, which can usually be reversed (usually -- like --triggers and --no-triggers, for example). Thus, I believe the -a flag should add to any args that were set in config files, rather than overwrite them. My particular use-case is this:

I have several database-driven webservices on a server. Each webservice has its own database and its own user. To safely handle user credentials per webservice using shmig, I'm using a service-specific my.cnf file, which I specify to mysql by setting ARGS="--defaults-extra-file=$PWD/my.cnf" in shmig.local.conf. However, I also have a deployment automater that I use to run shmig when I push the right git branch up, and that adds the -f argument on downward migrations to force mysql to continue with the entire migration script in the event of errors (only for downward migrations). My issue is that I don't want to specify --defaults-extra-file=... in both my shmig.local.conf and my deployment automator's command-line call to shmig.

kael-shipman commented 6 years ago

Ha! Joke's on me. Mysql requires that --defaults-extra-file be the first option, so this won't work anyway. The PR is small and potentially useful anyway, so I'll leave it at your discretion.

mbucc commented 5 years ago

Hey, I'm going to close this as won't fix. I'm not a fan of multiple configuration files or treating one argument as different from the others. Those both add complexity.

In this specific case, a possible solution (I think) is to alias mysql="mysql --defaults-extra-filey=$PWD/my.cnf" then pass -f to shmig.

In any case, the patch didn't fix your problem so I'm going to close it. Thanks!