]> git.koha-community.org Git - koha.git/commit
Bug 31143: Fix/identify all cases where '0000-00-00' may still remain in the database
authorwainuiwitikapark <wainuiwitikapark@catalyst.net.nz>
Tue, 24 Sep 2024 04:53:05 +0000 (04:53 +0000)
committerKatrin Fischer <katrin.fischer@bsz-bw.de>
Wed, 23 Oct 2024 18:02:20 +0000 (20:02 +0200)
commitd4bfae09778ef9f251b5a55b9446a50d66becd92
treed41c7a492ff0c8579c2ae9678f6f5c40f7767e98
parente048144d80097f45f43475f5730acbee328110cc
Bug 31143: Fix/identify all cases where '0000-00-00' may still remain in the database

This patch identifies date fields in the database (timestamp, datetime, date) that are 0000-00-00 and sets them to NULL

Test plan -

Examples of setting up some 0000-00-00 date fields:

e.g. Borrowers table
update borrowers set dateexpiry="0000-00-00" where borrowernumber=49;

e.g. Items table
update items set datelastseen="0000-00-00" where itemnumber=12;

To identify the cases:
1) Set up some 0000-00-00 date fields
2) Run the misc/maintenance/search_for_data_inconsistencies.pl script
3) Run fix_invalid_dates.pl -v

To fix the cases:
1) Run fix_invalid_dates.pl -c -v
2) Notice the value has changed from 0000-00-00 to NULL

e.g. Borrowers table
select dateexpiry from borrowers where borrowernumber=49;

e.g. Items table
select datelastseen from items where itemnumber=12;

Signed-off-by: Shi Yao Wang <shi-yao.wang@inlibro.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
misc/cronjobs/fix_invalid_dates.pl [new file with mode: 0755]
misc/maintenance/search_for_data_inconsistencies.pl