[Koha-bugs] [Bug 19963] New: ethnicity and ethnicity tables and columns survived update

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jan 12 12:44:04 CET 2018


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19963

            Bug ID: 19963
           Summary: ethnicity and ethnicity tables and columns survived
                    update
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P5 - low
         Component: Database
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: katrin.fischer at bsz-bw.de
        QA Contact: testopia at bugs.koha-community.org

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);

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list