Koha/installer/data/mysql/db_revs
Nick Clemens 254f721320
Bug 29012: Fix existing update to prevent inserting incorrect data
Both updates now rely on 'suspension_chargeperiod' as the source of truth
for existence of a rule. Spot checking some existing production databases this
seems to be acceptable.

This alters the update to only add rules where a 'suspension_chargeperiod' rule exists
and a value for the rule is not already set.

NOTE: While the table has a unique key:
UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`),

This key doesn't prevent duplicates on NULLs, i.e.:

branchcode  | categorycode  | itemtype  | rule_name                 | rule_value
NULL        | NULL          | BK        | unseen_renewals_allowed   | 1
NULL        | NULL          | BK        | unseen_renewals_allowed   | 2
NULL        | NULL          | BK        | unseen_renewals_allowed   | 3

So we need to both check that any rule is present and that the specific rule is not.
The 'INSERT IGNORE' won't IGNORE existing values except for the most specific rules

Test plan:
 0 - Edit and save existing default rule in DB (sample data does not include suspension_chargeperiod)
 1 - Set some rules for "Default checkout, hold and return policy" for "Standard rule" and some specific libraries
 2 - cp installer/data/mysql/db_revs/220600024.pl installer/data/mysql/atomicupdate/
 3 - SELECT * FROM circulation rules, note the number of rules that exist
 4 - updatedatabase
 5 - Check the DB again, you should now have rules as described in the bug
     i.e. You will have 5 new rules per 'Default checkout, hold and return policy'
 6 - apply 1st patch on bug
 7 - rm installer/data/mysql/atomicupdate/220600024.pl (so we don't add again)
 8 - updatedatabase
 9 - Check DB, the extra rules have been deleted
10 - Apply 2nd patch
11 - cp installer/data/mysql/db_revs/220600024.pl installer/data/mysql/atomicupdate/
12 - rm installer/data/mysql/atomicupdate/bug_31727.pl (so we can confirm update isn't adding rules)
13 - updatedatabase
14 - Confirm no change in rules since step 9
15 - git reset --hard (get deleted update back)
16 - rm installer/data/mysql/atomicupdate/220600024.pl

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-10-20 09:53:45 -03:00
..
210600000.pl
210600001.pl
210600002.pl
210600003.pl Bug 30185: Missing return in db rev 210600003.pl 2022-03-01 22:47:47 -10:00
210600004.pl
210600005.pl
210600006.pl
210600007.pl
210600008.pl
210600009.pl
210600010.pl
210600011.pl
210600012.pl Bug 29631: (QA follow-up) Add missing cleanups 2021-12-13 15:46:20 -10:00
210600013.pl Bug 29605: account_offsets.type is not null 2022-02-01 21:39:39 -10:00
210600014.pl
210600015.pl
210600016.pl
210600017.pl
210600018.pl
210600019.pl
210600020.pl
210600021.pl
210600022.pl Bug 29605: Missing FK on tmp_holdsqueue.borrowernumber (tmp_holdsqueue_ibfk_3) 2022-02-01 21:39:39 -10:00
210600023.pl
210600024.pl
210600025.pl
210600026.pl
210600027.pl
210600028.pl
210600029.pl
210600030.pl
210600031.pl Bug 29605: search_marc_map.marc_type 2022-02-01 21:39:39 -10:00
210600032.pl
210600033.pl
210600034.pl Bug 28831: DBRev 21.06.00.034 2021-10-18 11:28:41 +02:00
210600035.pl Bug 28153: (follow-up) Ensure update is idempotent 2021-10-19 15:30:57 +02:00
210600036.pl Bug 29200: DBRev 21.06.00.036 2021-10-21 12:24:04 +02:00
210600037.pl Bug 11175: DBRev 21.06.00.037 2021-10-26 16:46:02 +02:00
210600038.pl Bug 14957: DBRev 21.06.00.038 2021-10-26 16:46:03 +02:00
210600039.pl Bug 28959: DBRev 21.06.00.039 2021-10-28 17:47:46 +02:00
210600040.pl Bug 28263: DBRev 21.06.00.040 2021-11-02 16:50:01 +01:00
210600041.pl Bug 27360: (follow-up) DBRev 21.06.00.041 2021-11-15 12:38:39 +01:00
210600042.pl Bug 26326: Add missing +x flag 2021-11-04 10:38:54 +01:00
210600043.pl Bug 29386: DBRev 21.06.00.043 2021-11-05 12:10:45 +01:00
210600044.pl Bug 29180: DBRev 21.06.00.044 2021-11-05 12:17:08 +01:00
210600045.pl Bug 24223: DBRev 21.06.00.045 2021-11-08 11:41:46 +01:00
210600046.pl Bug 24224: DBRev 21.06.00.046 2021-11-08 11:42:06 +01:00
210600047.pl Bug 28374: DBRev 21.06.00.047 2021-11-15 12:38:39 +01:00
210600048.pl Bug 29341: DBRev 21.06.00.048 2021-11-19 15:23:27 +01:00
210600049.pl Bug 5229: DBRev 21.06.00.049 2021-11-19 15:23:27 +01:00
211100000.pl Koha 21.11.00 is here! 2021-11-26 12:26:48 +01:00
211200000.pl Koha 21.12 - start of a new dev cycle 2021-12-01 20:12:05 -10:00
211200001.pl Bug 29586: DB Rev 21.12.00.001 2021-12-13 16:02:55 -10:00
211200002.pl Bug 13188: DBRev 21.12.00.002 2021-12-14 09:48:51 -10:00
211200003.pl Bug 29457: DBRev 21.12.00.003 2021-12-21 20:44:15 -10:00
211200004.pl Bug 26296: DBrev 21.12.00.004 2022-01-09 21:04:17 -10:00
211200005.pl Bug 29778: DBREv 21.12.00.005 2022-01-09 21:04:17 -10:00
211200006.pl Bug 29557: DBRev 21.12.00.006 2022-01-11 12:38:35 -10:00
211200007.pl Bug 20076: DBRev 21.12.00.007 2022-01-13 16:37:33 -10:00
211200008.pl Bug 29495: DBRev 21.12.00.008 2022-01-17 14:55:56 -10:00
211200009.pl Bug 29336: DBRev 21.12.00.009 2022-01-18 21:15:05 -10:00
211200010.pl Bug 21729: DBRev 21.12.00.010 2022-01-28 11:09:06 -10:00
211200011.pl Bug 27946: DBRev 21.12.00.011 2022-01-28 11:09:07 -10:00
211200012.pl Bug 24220: DBRev 21.12.00.012 2022-01-31 21:55:40 -10:00
211200013.pl Bug 29605: DBRev 21.12.00.013 2022-02-01 21:39:39 -10:00
211200014.pl Bug 29596: DBRev 21.12.00.014 2022-02-01 21:39:39 -10:00
211200015.pl Bug 29943: DBRev 21.12.00.015 2022-02-01 21:39:39 -10:00
211200016.pl Bug 30912: Fix db rev 21.12.00.016 2022-06-13 10:54:55 -03:00
211200017.pl Bug 30128: DBrev 21.12.00.017 2022-03-08 23:03:34 -10:00
211200018.pl Bug 30600: Fix recall reasons for branch transfers 2022-05-04 14:29:23 -10:00
211200019.pl Bug 27812: DBRev 21.12.00.019 2022-03-17 11:22:56 -10:00
211200020.pl Bug 24221: DBRev 21.12.00.020 2022-03-25 11:01:04 -10:00
211200021.pl Bug 30063: DBRev 21.12.00.021 2022-04-04 16:35:53 +02:00
211200022.pl Bug 11083: DBRev 21.12.00.022 2022-04-08 15:49:15 +02:00
211200023.pl Bug 20517: DBRev 21.12.00.023 2022-04-08 15:49:17 +02:00
211200024.pl Bug 20398: DBRev 21.12.00.024 2022-04-08 15:49:17 +02:00
211200025.pl Bug 29990: DBRev 21.12.00.025 2022-04-08 15:49:18 +02:00
211200026.pl Bug 17018: DBRev 21.12.00.026 2022-04-12 17:13:02 +02:00
211200027.pl Bug 26346: DBRev 21.12.00.027 2022-04-12 17:13:02 +02:00
211200028.pl Bug 16258: Add DBRev 21.12.00.028 2022-04-13 15:55:39 +02:00
211200029.pl Bug 30130: Add DBRev 21.12.00.029 2022-04-13 15:55:39 +02:00
211200030.pl Bug 30135: DBRev 21.12.00.030 2022-04-13 15:55:39 +02:00
211200031.pl Bug 30481: DBRev 21.12.00.031 2022-04-13 15:55:39 +02:00
211200032.pl Bug 30498: DBRev 21.12.00.032 2022-04-13 15:55:40 +02:00
211200033.pl Bug 27783: DBRev 21.12.00.033 2022-04-13 15:55:40 +02:00
211200034.pl Bug 30237: DBRev 21.12.00.034 2022-04-20 09:03:39 -10:00
211200035.pl Bug 30226: DBRev 21.12.00.035 2022-04-20 20:43:15 -10:00
211200036.pl Bug 28786: DBRev 21.12.00.036 2022-04-20 20:43:15 -10:00
211200037.pl Bug 27253: (follow-up) Fix UNIXTIME(0) in db_revs/211200037.pl 2022-04-25 10:00:22 -10:00
211200038.pl Bug 29648: DBRev 21.12.00.038 2022-04-27 11:20:45 -10:00
211200039.pl Bug 29092: DBRev 21.12.00.039 2022-04-27 11:20:45 -10:00
211200040.pl Bug 30565: DBRev 21.12.00.040 2022-05-02 11:22:57 -10:00
211200041.pl Bug 30899: Correct dbrev 211200041 2022-06-08 11:04:57 -03:00
211200042.pl Bug 30572: DBRev 21.12.00.042 2022-05-02 11:22:57 -10:00
211200043.pl Bug 30108: DBRev 21.12.00.043 2022-05-02 11:22:58 -10:00
211200044.pl Bug 29894: DBRev 21.12.00.044 2022-05-02 11:22:58 -10:00
211200045.pl Bug 14242: DBRev 21.12.00.045 2022-05-03 11:19:50 -10:00
211200046.pl Bug 22785: DBRev 21.12.00.046 2022-05-03 11:19:50 -10:00
211200047.pl Bug 28138: DBRev 21.12.00.047 2022-05-04 14:29:23 -10:00
211200048.pl Bug 30291: DBRev 21.12.00.048 2022-05-05 11:17:36 -10:00
211200049.pl Bug 30563: DBRev 21.12.00.049 2022-05-06 10:33:09 -10:00
211200050.pl Bug 29924: DBRev 21.12.00.050 2022-05-06 10:33:09 -10:00
211200051.pl Bug 29925: DBRev 21.12.00.051 2022-05-06 10:33:09 -10:00
211200052.pl Bug 30290: DBRev 21.12.00.052 2022-05-10 15:17:17 -10:00
211200053.pl Bug 30611: DBRev 21.12.00.053 2022-05-10 15:17:17 -10:00
211200054.pl Bug 23352: DBRev 21.12.00.054 2022-05-10 15:17:18 -10:00
211200055.pl Bug 13142: DBRev 21.12.00.055 2022-05-10 23:09:09 -10:00
211200056.pl Bug 30728: Fix typo 'in real time' 2022-05-12 22:17:46 -10:00
211200057.pl Bug 30852: DBRev 21.12.00.057 2022-05-25 20:36:34 -10:00
220500000.pl Koha 22.05.00 is here! 2022-05-25 23:56:14 -10:00
220600000.pl Koha 22.06 - start of a new dev cycle 2022-05-31 08:43:28 -03:00
220600001.pl Bug 23659: DBRev 22.06.00.001 2022-06-06 11:43:41 -03:00
220600002.pl Bug 30850: DBRev 22.06.00.002 2022-06-08 11:25:26 -03:00
220600003.pl Bug 30924: DBRev 22.06.00.003 2022-06-16 11:36:43 -03:00
220600004.pl Bug 12446: (QA follow-up) Rename canbeguarantee => can_be_guarantee 2022-06-23 13:34:05 -03:00
220600005.pl Bug 24239: DBRev 22.06.00.005 2022-06-23 15:55:54 -03:00
220600006.pl Bug 21978: DBRev 22.06.00.006 2022-06-24 12:31:39 -03:00
220600007.pl Bug 29129: DBRev 22.06.00.007 2022-06-25 11:16:23 -03:00
220600008.pl Bug 30327: DBRev 22.06.00.008 2022-06-25 15:30:47 -03:00
220600009.pl Bug 30889: DBRev 22.06.00.009 2022-07-01 09:14:18 -03:00
220600010.pl Bug 30823: DBRev 22.06.00.010 2022-07-01 16:13:52 -03:00
220600011.pl Bug 30275: DBRev 22.06.00.011 2022-07-05 09:50:05 -03:00
220600012.pl Bug 24010: DBRev 22.06.00.012 2022-07-05 11:11:54 -03:00
220600013.pl Bug 31170: (QA follow-up) Fix capitalization in database update 2022-09-07 12:04:55 -07:00
220600014.pl Bug 24857: DBRev 22.06.00.014 2022-07-08 16:23:05 -03:00
220600015.pl Bug 28854: DBRev 22.06.00.015 2022-07-13 12:21:05 -03:00
220600016.pl Bug 28854: Fix permissions problem 2022-07-13 19:09:39 -03:00
220600017.pl Bug 29632: (QA follow-up) Fix COMMENT discrepancy on upgrade 2022-08-04 09:55:16 -03:00
220600018.pl Bug 11889: DBRev 22.06.00.018 2022-07-19 11:21:00 -03:00
220600019.pl Bug 30933: DBRev 22.06.00.019 2022-07-20 09:16:47 -03:00
220600020.pl Bug 31673: (QA follow-up) Check if FK exists before attempt to remove 2022-10-11 09:08:56 -03:00
220600021.pl Bug 31157: DBRev 22.06.00.021 2022-07-22 15:18:06 -03:00
220600022.pl Bug 30650: (QA follow-up) Fix TINYINT fields discrepancy on upgrade 2022-08-04 09:47:38 -03:00
220600023.pl Bug 22456: DBRev 22.06.00.023 2022-07-29 15:33:13 -03:00
220600024.pl Bug 29012: Fix existing update to prevent inserting incorrect data 2022-10-20 09:53:45 -03:00
220600025.pl Bug 14364: DBRev 22.06.00.025 2022-07-29 16:06:12 -03:00
220600026.pl Bug 30984: DBRev 22.06.00.026 2022-08-01 09:26:59 -03:00
220600027.pl Bug 23919: DBRev 22.06.00.027 2022-08-01 14:12:30 -03:00
220600028.pl Bug 30077: DBRev 22.06.00.028 2022-08-01 14:13:37 -03:00
220600029.pl Bug 30392: DBRev 22.06.00.029 2022-08-01 14:35:35 -03:00
220600030.pl Bug 31274: DBRev 22.06.00.030 2022-08-02 09:30:28 -03:00
220600031.pl Bug 30879: DBRev 22.06.00.031 2022-08-02 09:41:54 -03:00
220600032.pl Bug 30500: DBRev 22.06.00.032 2022-08-05 11:56:24 -03:00
220600033.pl Bug 27779: DBRev 22.06.00.033 2022-08-08 13:40:13 -03:00
220600034.pl Bug 29897: DBRev 22.06.00.034 2022-08-09 11:58:06 -03:00
220600035.pl Bug 28787: DBRev 22.06.00.035 2022-08-09 13:42:21 -03:00
220600036.pl Bug 31017: DBRev 22.06.00.036 2022-08-19 16:26:23 -03:00
220600037.pl Bug 23681: DBRev 22.06.00.037 2022-08-25 08:50:41 -03:00
220600038.pl Bug 30335: Fix DBRev permissions 2022-08-31 10:18:23 -03:00
220600039.pl Bug 31374: DBRev 22.06.00.039 2022-09-07 13:36:52 -07:00
220600040.pl Bug 30619: DBRev 22.06.00.040 2022-09-07 17:50:18 -07:00
220600041.pl Bug 30483: DBRev 22.06.00.041 2022-09-12 08:39:03 -03:00
220600042.pl Bug 27981: DBRev 22.06.00.042 2022-09-12 15:21:38 -03:00
220600043.pl Bug 20058: DBRev 22.06.00.043 2022-09-12 17:45:52 -03:00
220600044.pl Bug 26247: (follow-up) Fix permissions 2022-09-13 21:03:20 -03:00
220600045.pl Bug 29144: DBRev 22.06.00.045 2022-09-16 10:25:07 -03:00
220600046.pl Bug 15348: DBRev 22.06.00.046 2022-09-16 10:59:04 -03:00
220600047.pl Bug 30025: DBRev 22.06.00.047 2022-09-16 16:52:16 -03:00
220600048.pl Bug 30472: DBRev 22.06.00.048 2022-09-16 16:56:44 -03:00
220600049.pl Bug 30490: DBRev 22.06.00.049 2022-09-22 08:33:09 -03:00
220600050.pl Bug 30497: DBRev 22.06.00.050 2022-09-22 08:38:10 -03:00
220600051.pl Bug 7021: DBRev 22.06.00.051 2022-09-22 09:43:41 -03:00
220600052.pl Bug 25375: DBRev 22.06.00.052 2022-09-23 09:13:24 -03:00
220600053.pl Bug 30484: DBRev 22.06.00.053 2022-09-23 09:33:43 -03:00
220600054.pl Bug 23538: DBRev 22.06.00.054 2022-09-23 09:42:05 -03:00
220600055.pl Bug 26368: DBRev 22.06.00.055 2022-10-03 08:20:41 -03:00
220600056.pl Bug 30571: (follow-up) Additional check at upgrade 2022-10-12 09:04:06 -03:00
220600057.pl Bug 29071: DBRev 22.06.00.057 2022-10-03 08:49:22 -03:00
220600058.pl Bug 30944: DBRev 22.06.00.058 2022-10-03 13:47:37 -03:00
220600059.pl Bug 25936: DBRev 22.06.00.059 2022-10-03 14:30:39 -03:00
220600060.pl Bug 10950: DBRev 22.06.00.060 2022-10-03 15:05:01 -03:00
220600061.pl Bug 31333: DBRev 22.06.00.061 2022-10-05 16:02:04 -03:00
220600062.pl Bug 27136: DBRev 22.06.00.062 2022-10-12 14:54:23 -03:00
220600063.pl Bug 31569: DBRev 22.06.00.063 2022-10-17 08:23:36 -03:00
220600064.pl Bug 14783: (follow-up) Fix problematic db_rev 2022-10-18 09:02:44 -03:00
220600065.pl Bug 25426: DBRev 22.06.00.065 2022-10-18 09:38:05 -03:00
220600066.pl Bug 31626: DBRev 22.06.00.066 2022-10-18 09:54:08 -03:00