The database update for 3.21.00.033 should have removed the ethnicity table and the ethnicity and ethnotes columns from borrowers, deletedborrowers and borrower_modifications. This didn't work right in all cases. I just noticed that all those survived in our older databases. The reason is that the database update only checked for NULL when counting existing data, but not for "": 11054 $DBversion = "3.21.00.033"; 11055 if ( CheckVersion($DBversion) ) { 11056 11057 my $done = 0; 11058 my $count_ethnicity = $dbh->selectrow_arrayref(q| 11059 SELECT COUNT(*) FROM ethnicity 11060 |); 11061 my $count_borrower_modifications = $dbh->selectrow_arrayref(q| 11062 SELECT COUNT(*) 11063 FROM borrower_modifications 11064 WHERE ethnicity IS NOT NULL 11065 OR ethnotes IS NOT NULL 11066 |); 11067 my $count_borrowers = $dbh->selectrow_arrayref(q| 11068 SELECT COUNT(*) 11069 FROM borrowers 11070 WHERE ethnicity IS NOT NULL 11071 OR ethnotes IS NOT NULL 11072 |); 11073 # We don't care about the ethnicity of the deleted borrowers, right? 11074 if ( $count_ethnicity->[0] == 0 11075 and $count_borrower_modifications->[0] == 0 11076 and $count_borrowers->[0] == 0 11077 ) { 11078 $dbh->do(q| 11079 DROP TABLE ethnicity 11080 |); 11081 $dbh->do(q| 11082 ALTER TABLE borrower_modifications 11083 DROP COLUMN ethnicity, 11084 DROP COLUMN ethnotes 11085 |); 11086 $dbh->do(q| 11087 ALTER TABLE borrowers 11088 DROP COLUMN ethnicity, 11089 DROP COLUMN ethnotes 11090 |); 11091 $dbh->do(q| 11092 ALTER TABLE deletedborrowers 11093 DROP COLUMN ethnicity, 11094 DROP COLUMN ethnotes 11095 |); 11096 $done = 1; 11097 } 11098 if ( $done ) { 11099 print "Upgrade to $DBversion done (Bug 10020: Drop table ethnicity and columns ethnicity and ethnotes)\n"; 11100 } 11101 else { 11102 print "Upgrade to $DBversion done (Bug 10020: This database contains data related to 'ethnicity'. No change will be done on the DB structure but note that the Koha codebase does not use it)\n"; 11103 } 11104 11105 SetVersion ($DBversion);
I guess this change could fix it, but do not have more time to spend on that. There is the warning that is displayed anyway.
Created attachment 70806 [details] [review] Bug 19963: Update 3.21.00.033 to drop ethnicity data if ''
I'm guessing this is still valid? Doesn't appear in new databases but guessing it still affects old ones?
Yes it would, we probably missed Jobou's patch because the status wasn't changed?