jethro-pmm
jethro-pmm copied to clipboard
Deleting a congregation fails if attendance 'Total Headcount' was recorded
Jethro allows one to delete a congregation once all members are removed from it:
Any attendance records are left untouched in the database, since they are associated with the person, not the congregation directly.
However, if, while marking attendances, one ever recorded the 'Total headcount':
The headcount is associated with the congregation - the congregation_headcount
table's congregationid
refers to it.
MariaDB [jethro]> select * from congregation where id=15;
+----+-----------+----------+--------------+---------------------------+---------------+
| id | long_name | name | meeting_time | attendance_recording_days | holds_persons |
+----+-----------+----------+--------------+---------------------------+---------------+
| 15 | TestCong | Testcong | | 127 | 1 |
+----+-----------+----------+--------------+---------------------------+---------------+
MariaDB [jethro]> select * from congregation_headcount where date='2024-10-20';;
+------------+----------------+--------+
| date | congregationid | number |
+------------+----------------+--------+
| 2024-10-20 | 15 | 123 |
+------------+----------------+--------+
The congregation appears deletable, but doing so results in "An error occurred. Please contact your system administrator for help.", and an error.log
entry:
AH01071: Got error 'PHP message: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`jethro`.`congregation_headcount`, CONSTRAINT `congregation_headcount_congid2` FOREIGN KEY (`congregationid`) REFERENCES `congregation` (`id`)) - Line 481 of /srv/www/jethro/2.35.1/app/include/db_object.class.php