SidewalkWebpage
SidewalkWebpage copied to clipboard
Some tables in the db are missing foreign key constraints
Brief description of problem/feature
I was working on a short SQL script to remove PII from a db so that we could send it to others, but I noticed that removing data wasn't cascading to all the tables you'd expect. The reason is that foreign key constraints are missing in a few places. Going to list what I've found here. I'll go through and add the constraints when I can, and then remove the extra calls from my script to remove PII!
user_roletable needsFOREIGN KEY(user_id) REFERENCES sidewalk_user(user_id)user_roletable needsFOREIGN KEY(role_id) REFERENCES role(role_id)user_current_regiontable needsFOREIGN KEY(user_id) REFERENCES sidewalk_user(user_id)user_current_regiontable needsFOREIGN KEY(region_id) REFERENCES region(region_id)label_pointtable needsFOREIGN KEY(label_id) REFERENCES label(label_id)validation_task_interactiontable needsFOREIGN KEY(mission_id) REFERENCES mission(mission_id)
I'm sure there are plenty of other places where such constraints are missing. Might be worth it to just spend an hour combing through our tables and getting them cleaned up at some point.