AOSSIE-Org / AOSSIE-Org/BabyNest
BUG:Missing Foreign Key Relationship with profile_id Causing Unlinked Records
- Ngôn ngữ chính
- JavaScript
- Star
- 56
- Fork
- 124
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### Is there an existing issue for this?
- [x] I have searched the existing issues
### What happened?
## 📌 Issue Overview
Several tables do not contain a foreign key referencing the `profile` table.
Because of this, created records are not bound to any user/profile, resulting in orphan data and inability to correctly query user-specific records.
Create a profile
2. Insert records in any of the following tables:
- appointments
- tasks
- blood_pressure_logs
- discharge_logs
- weekly_weight
- weekly_medicine
- weekly_symptoms
3. Try to fetch records by user/profile
4. Notice that there is no reliable way to associate entries with a specific profile
## 🎯 Expected Behavior
Every record should be linked to a profile through a `profile_id` foreign key, ensuring:
- proper relational integrity
- user-specific data retrieval
- automatic cleanup when a profile is deleted
## 🚨 Actual Behavior
Records are stored without any relationship to the profile,
leading to:
- orphan database rows
- incorrect or mixed user data
- data inconsistency
## 💡 Suggested Fix
Add a `profile_id INTEGER NOT NULL` column with a foreign key constraint:
```sql
ALTER TABLE
ADD COLUMN profile_id INTEGER NOT NULL REFERENCES profile(id) ON DELETE CASCADE;
- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.