When you delete a branch that has holidays specified in special_holidays, these entries don't get deleted. To recreate: - add an calendar entry to Calendar for this branch - select * from special_holidays where branchcode = 'YOUR BRANCH'; - delete branch from Administration -> Libraries - select *.... holidays are still there for that branchcode
Created attachment 96630 [details] [review] Bug 24289: Add foreign keys on *_holidays.branchcode tables Those are missing foreign keys, it will also clean the holidays tables and automatically remove the holidays when a library is removed. Test plan: 0. Do not apply this patch 1. Create a new library 2. Create special and repeatable holiday for this library 3. Remove the library => Notice that the holidays still exist in DB 4. Apply this patch 5. Execute the update database entry => Notice that the holidays for this library have been removed from the DB 6. Repeat 1-3 => Notice that the holidays have been removed along with the library
Created attachment 96631 [details] [review] Bug 24289: DBIC changes
Created attachment 96632 [details] [review] Bug 24289: Make sure sample_holidays will load after sample_libraries They are inserted depending on their alpha order, and sample_holidays will fail because of missing branchcode. This patch suggests a simple fix: rename sample_holidays to sample_libraries_holidays, to make sure it will be loaded after sample_libraries Test plan: Start a fresh installation and select all sample data
Created attachment 97410 [details] [review] Bug 24289: Add foreign keys on *_holidays.branchcode tables Those are missing foreign keys, it will also clean the holidays tables and automatically remove the holidays when a library is removed. Test plan: 0. Do not apply this patch 1. Create a new library 2. Create special and repeatable holiday for this library 3. Remove the library => Notice that the holidays still exist in DB 4. Apply this patch 5. Execute the update database entry => Notice that the holidays for this library have been removed from the DB 6. Repeat 1-3 => Notice that the holidays have been removed along with the library
Created attachment 97411 [details] [review] Bug 24289: DBIC changes
Created attachment 97412 [details] [review] Bug 24289: Make sure sample_holidays will load after sample_libraries They are inserted depending on their alpha order, and sample_holidays will fail because of missing branchcode. This patch suggests a simple fix: rename sample_holidays to sample_libraries_holidays, to make sure it will be loaded after sample_libraries Test plan: Start a fresh installation and select all sample data
*** Bug 18874 has been marked as a duplicate of this bug. ***
Created attachment 97600 [details] [review] Bug 24289: Add foreign keys on *_holidays.branchcode tables Those are missing foreign keys, it will also clean the holidays tables and automatically remove the holidays when a library is removed. Test plan: 0. Do not apply this patch 1. Create a new library 2. Create special and repeatable holiday for this library 3. Remove the library => Notice that the holidays still exist in DB 4. Apply this patch 5. Execute the update database entry => Notice that the holidays for this library have been removed from the DB 6. Repeat 1-3 => Notice that the holidays have been removed along with the library Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Created attachment 97601 [details] [review] Bug 24289: DBIC changes Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Created attachment 97602 [details] [review] Bug 24289: Make sure sample_holidays will load after sample_libraries They are inserted depending on their alpha order, and sample_holidays will fail because of missing branchcode. This patch suggests a simple fix: rename sample_holidays to sample_libraries_holidays, to make sure it will be loaded after sample_libraries Test plan: Start a fresh installation and select all sample data Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Nice work everyone! Pushed to master for 20.05
Pushed to 19.11.x branch for 19.11.03
backported to 19.05.x for 19.05.08
On December I installed an instance based on koha stable without any issue. Today I get this error on web installer, while adding sample data. Seems related to this bug: sample_libraries_holidays.sql [Wed May 13 19:24:37 2020] install.pl: DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_mylibrary`.`repeatable_holidays`, CONSTRAINT `repeatable_holidays_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE) at /usr/share/perl5/DBIx/RunSQL.pm line 273.
(In reply to Pablo AB from comment #14) > On December I installed an instance based on koha stable without any issue. > Today I get this error on web installer, while adding sample data. Seems > related to this bug: > > sample_libraries_holidays.sql > [Wed May 13 19:24:37 2020] install.pl: DBD::mysql::st execute failed: Cannot > add or update a child row: a foreign key constraint fails > (`koha_mylibrary`.`repeatable_holidays`, CONSTRAINT > `repeatable_holidays_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES > `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE) at > /usr/share/perl5/DBIx/RunSQL.pm line 273. Did you pick the sample libraries as well?
> Did you pick the sample libraries as well? Probably not. I believe I just wanted to have some basic holidays set (for all branches) without adding the sample libraries. Now reading the sql filename I realize this might not be possible. Checkboxes have dependencies between each which are not validated?
There is no validation (it should). The holidays tables have a foreign key on branches.branchcode, so you need the sample libraries as well.