ABTech / tracker

Carnegie Mellon Activities Board Technical Committee Tracker
abtech.org
22 stars 29 forks source link

Add foreign key constraint and relationship checks from timecard_entry to eventdate #529

Open NoRePercussions opened 1 year ago

NoRePercussions commented 1 year ago

Prevent inconsistency when eventdates are deleted by enforcing that timecard entries must reference a valid eventdate.

This commit alone does not update the UI in response to this change. At minimum, the delete eventdate button should be disabled if there is at least one timecard.

NoRePercussions commented 1 year ago

Form-level validation is fixed. My theory is that the destroyed eventdates are being removed from the event before they are validated, thus no form errors. I added another validator to event that checks each eventdate that will be destroyed.

DaAwesomeP commented 10 months ago

I am hesitant to go forward with this. If these constraints have not been implemented for so long then there is a strong chance that adding them will expose some missing data in Tracker. I was having lot of issues with these commits: https://github.com/ABTech/tracker/commit/1a918f53d0187235b39fdd4991978bf1a36090c8 and https://github.com/ABTech/tracker/commit/60a3d3d24ff8b35bb545d8ee37cc01532263e638. I ultimately had to disable the check in prod because looping over the events in the migration would fail due to validations created after those events: https://github.com/ABTech/tracker/commit/a025884794d0af3253d99cfa8c3f33ee42131350

I think that this and some of your other pulls warrant a return of a full dev instance of Tracker (i.e. copy the prod DB to a dev instance).