Bug 30912: Fix db rev 21.12.00.016
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 13 Jun 2022 13:17:22 +0000 (10:17 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 13 Jun 2022 13:54:55 +0000 (10:54 -0300)
commitd3e6c3c7090ed706a152c6c465efc767fc0428c1
tree8c0e75a062ef4dba863dfec3e5bb776639a38353
parent48d4b016ab8f5b7199efe75384c592e39e5dfce6
Bug 30912: Fix db rev 21.12.00.016

This is a mix of Nick's patch and Jonathan's comment on it. I tested it
with KTD using MySQL 8 and it works correctly.

To test:
1. Launch KTD with bells and whistles:
   $ docker compose -f docker-compose.yml \
                    -f docker-compose.mysql8.0.yml \
                    up -d
2. Inside of it, do:
   $ koha-mysql kohadev
   > update systempreferences set value="21.1200015" where variable="version";
   > \q
   $ restart_all
   $ updatedatabase
=> SUCCESS: All good :-D
3. Run:
   $ koha-mysql kohadev
   > update systempreferences set value="21.1200015" where variable="version";
   > ALTER TABLE user_permissions DROP PRIMARY KEY;
   > \q
   $ updatedatabase
=> FAIL: You get:
Upgrade to 21.12.00.016  [12:47:09]: Bug 30060 - Update user_permissions to add primary key and remove null option from code column
ERROR - {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS `PRIMARY`' at line 1 at /kohadevbox/koha/C4/Installer.pm line 739
4. Apply this patch
5. Run:
   $ updatedatabase
=> SUCCESS: Update goes well
6. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/db_revs/211200016.pl