Bug 14533 - koha-create --use-db option shouldn't create any db or db user
Summary: koha-create --use-db option shouldn't create any db or db user
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Mark Tompsett
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 18877
  Show dependency treegraph
 
Reported: 2015-07-14 14:44 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2018-06-04 20:10 UTC (History)
6 users (show)

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


Attachments
Patch - remove CREATE USER when koha-create --use-db (716 bytes, patch)
2015-08-06 23:29 UTC, Yarik Dot
Details | Diff | Splinter Review
Bug 14533: remove CREATE USER when koha-create --use-db (1.04 KB, patch)
2017-06-22 17:53 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14533: Deal with comment #2 (1.11 KB, patch)
2017-06-22 19:29 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14533: Deal with comment #2 (1.10 KB, patch)
2017-06-22 19:31 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14533: remove CREATE USER when koha-create --use-db (1.09 KB, patch)
2017-06-28 22:17 UTC, Lee Jamison
Details | Diff | Splinter Review
Bug 14533: Deal with comment #2 (1.15 KB, patch)
2017-06-28 22:17 UTC, Lee Jamison
Details | Diff | Splinter Review
Bug 14533: remove CREATE USER when koha-create --use-db (1.14 KB, patch)
2017-08-11 17:53 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 14533: Make --use-db display a message if no DB defined (1.23 KB, patch)
2017-08-11 17:53 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2015-07-14 14:44:59 UTC
It is counter-intuitive to have an option switch --use-db which tries to create a db (what is --create-db for then?) and also a db user... It is of more use to just pass it the data for using an already created db with its credentials.
Comment 1 Yarik Dot 2015-08-06 23:29:52 UTC
Created attachment 41424 [details] [review]
Patch - remove CREATE USER when koha-create --use-db

Please, check the attachment.
Comment 2 Tomás Cohen Arazi (tcohen) 2015-08-07 14:41:45 UTC
(In reply to Yarik Dot from comment #1)
> Created attachment 41424 [details] [review] [review]
> Patch - remove CREATE USER when koha-create --use-db
> 
> Please, check the attachment.

I think the behaviour should be:

- If the user passes DB parameters (user, pass, hostname, dbname), use them to configure the instance. This needs more parameters to be added to koha-create. hostname should default to 'localhost' if ommited.
- If some of the new parameters is missing, fallback to what is configured in /etc/koha/passwd.
- If some of the relevant parameters is missing, fail loudly.
Comment 3 Tomás Cohen Arazi (tcohen) 2015-08-07 14:43:43 UTC
Comment on attachment 41424 [details] [review]
Patch - remove CREATE USER when koha-create --use-db

-    if [ "$op" = use ]
-    then
-        mysql --defaults-extra-file=/etc/mysql/koha-common.cnf --force <<eof
-CREATE USER \`$mysqluser\`@'$mysql_hostname' IDENTIFIED BY '$mysqlpwd';
-CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
-GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
-FLUSH PRIVILEGES;
-eof
-    fi #`
-

This is not enough, as the DB is still being created. Look at my previous comment
Comment 4 Yarik Dot 2015-08-11 11:43:59 UTC
(In reply to Tomás Cohen Arazi from comment #2)
> 
> I think the behaviour should be:
> 
> - If the user passes DB parameters (user, pass, hostname, dbname), use them
> to configure the instance. This needs more parameters to be added to
> koha-create. hostname should default to 'localhost' if ommited.

There is currently /etc/mysql/koha-common.cnf used right? Why to change this behavior?

If there is nothing defined in here, default client configuration from /etc/mysql/my.cnf is used.

Anyway, I am ok with changing this behaviour if the change is consistent. That means, there won't be 10 places where the database connection can be defined.

> - If some of the new parameters is missing, fallback to what is configured
> in /etc/koha/passwd.

Why? That is why passwdfile is used, isn't it?

> - If some of the relevant parameters is missing, fail loudly.

Agree.

-------

To explain more how we use it:

first# koha-create --request-db
mysql# mysql; CREATE DB ...; GRANT ...;
first# koha-create --populate-db
second# koha-create --use-db --passwdfile ./file

(In reply to Tomás Cohen Arazi from comment #3)
> This is not enough, as the DB is still being created. Look at my previous
> comment

I have just double checked the koha-create script and database is only created when --create is used. It is on line 560 and nowhere else.
Comment 5 Mark Tompsett 2017-06-22 16:45:58 UTC
Is this ready for sign off?
Comment 6 Mark Tompsett 2017-06-22 17:53:59 UTC
Created attachment 64552 [details] [review]
Bug 14533: remove CREATE USER when koha-create --use-db
Comment 7 Mark Tompsett 2017-06-22 17:56:15 UTC
Comment on attachment 41424 [details] [review]
Patch - remove CREATE USER when koha-create --use-db

This was not a 'git bz attach'd patch. Provided one to make testing easier.
Comment 8 Mark Tompsett 2017-06-22 19:29:20 UTC
Created attachment 64554 [details] [review]
Bug 14533: Deal with comment #2
Comment 9 Mark Tompsett 2017-06-22 19:31:03 UTC
Created attachment 64555 [details] [review]
Bug 14533: Deal with comment #2
Comment 10 Lee Jamison 2017-06-28 22:17:33 UTC
Created attachment 64712 [details] [review]
Bug 14533: remove CREATE USER when koha-create --use-db

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Comment 11 Lee Jamison 2017-06-28 22:17:50 UTC
Created attachment 64713 [details] [review]
Bug 14533: Deal with comment #2

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Comment 12 Tomás Cohen Arazi (tcohen) 2017-08-11 17:53:32 UTC
Created attachment 65920 [details] [review]
Bug 14533: remove CREATE USER when koha-create --use-db

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 13 Tomás Cohen Arazi (tcohen) 2017-08-11 17:53:41 UTC
Created attachment 65921 [details] [review]
Bug 14533: Make --use-db display a message if no DB defined

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 14 Jonathan Druart 2017-08-15 15:26:04 UTC
Pushed to master for 17.11, thanks to everybody involved!
Comment 15 Jonathan Druart 2017-08-15 15:35:52 UTC
Congratulation Yarik and thanks for your first patch!
Comment 16 Fridolin Somers 2017-09-29 10:27:22 UTC
Enhancement not pushed to 17.05.x