If koha-create is given the path to a DEFAULTSQL in /etc/koha/koha-sites.conf, it looks like it expects to find a statement similar to this at the top of that file: use koha___KOHASITE__; This piece of the code will then replace __KOHASITE__ with the name of the site being created: # Populate the database with default content. zcat "$DEFAULTSQL" | sed "s/__KOHASITE__/$name/g" | mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpwd" As far as I can see this means one has to remember to add the use koha___KOHASITE__; to the file whenever a new DEFAULTSQL is created. Wouldn't it be easier and less error prone to make mysql use the right database by including the name of the database in the call to mysql? Something like this: # Populate the database with default content. zcat "$DEFAULTSQL" | mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpwd" $mysqldb
Did you use "koha-dump-defaults" to produce the default SQL? I think that this should take care of it for you.
Ah, no I used plain ol' mysqldump. But I think it would be good if it was possible to make a mysqldump on a system not running from the packages and then base installs made with the packages on that.
You can, use '--all-databases' when running mysqldump (but still provide the database name.) Keep in mind that part of the script is to replace the name of the instance with the placeholder, so that you can make it refer to itself (perhaps a default title or paths or something) and it'll replace that when it's installed to an instance. So it's still handy if you're in a position to use it.
oh, --all-databases will put in the exact database name which isn't so good for a template. So your idea is still worthwhile :)
Created attachment 4537 [details] [review] Proposed patch This patch makes sure that pointing DEFAULTSQL in /etc/koha/koha-sites.conf to any (gzip'ed) file produced by mysqldump works, by adding the name of the database to the end of the call to mysql, when the specified SQL file is loaded. Files produced with koha-dump-defaults should still work too. To test: - Apply the patch - Create an SQL file from an existing installation with mysqldump - gzip the SQL file - point DEFAULTSQL to the file in /etc/koha/koha-sites.conf - create a new site with koha-create --create-db
I suggest that the variable $mysqldb should be quoted. There isn't difference in general case, but it is a better practice to quote arguments.
Created attachment 4538 [details] [review] Revised patch The revised patch quotes the variable $mysqldb, as suggested by Frère Sébastien Marie.
Created attachment 4549 [details] [review] Bug 6517 - [REVISED] koha-create wants "use database" in DEFAULTSQL The revised patch quotes the variable $mysqldb, as suggested by Frère Sébastien Marie. This patch makes sure that pointing DEFAULTSQL in /etc/koha/koha-sites.conf to any (gzip'ed) file produced by mysqldump works, by adding the name of the database to the end of the call to mysql, when the specified SQL file is loaded. Files produced with koha-dump-defaults should still work too. To test: - Apply the patch - Create a new package with build-git-snapshot - Install the package - Create an SQL file from an existing installation with mysqldump - gzip the SQL file - point DEFAULTSQL to the file in /etc/koha/koha-sites.conf - create a new site with koha-create --create-db Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Packaging only bug, please test
The fix for this bug was published in the 3.4.5 release. If you were the reporter of this bug, please take time to verify the fix and update the status of this bug report accordingly. If the bug is fixed to your satisfaction, please close this report.