Problem
Currently, EditHabitModal.tsx allows users to freely change a habit’s name (title).
This creates a data integrity issue:
- A habit like "Drink water" can be renamed to "Read in the morning"
- All existing logs (e.g. 40 days) are then incorrectly associated with the new meaning
- This rewrites the user’s historical data and breaks trust
A habit with existing logs should not change its meaning, only its presentation.
Goal
Preserve historical accuracy by preventing direct renaming of habits that already have logs.
Instead, when a habit has logs and the user changes its name:
- The original habit remains unchanged
- A new habit is created with the new name
- The streak and logs start fresh for the new habit
Proposed Solution (Option A)
Business Rule
- ✅ If a habit has no logs → allow editing the name normally
- ❌ If a habit has at least one log → do NOT rename it
When logs exist and the title is changed:
- Show a confirmation modal explaining the consequence
- If confirmed:
- Create a new habit with the updated title
- Keep the old habit and its logs intact
UX Behavior
When the user tries to change the name of a habit with existing logs:
Modal message (example):
This habit already has recorded history.
Changing its name will create a new habit and keep the previous history intact.
Actions:
Technical Notes
Location
Required Checks
Before updating the habit title:
SELECT 1
FROM habit_logs
WHERE habit_id = $1
LIMIT 1;
Logic Flow
- If no logs → update habit normally
- If logs exist AND title changed:
- Prevent direct update
- Prompt confirmation
- On confirm:
- Insert new row into
habits
- Do not modify the original habit
No database migrations are required.
Acceptance Criteria
Future Considerations
This approach intentionally avoids habit versioning for now.
A future improvement could introduce:
- Habit versioning
- Archived habits
- More granular edit rules
This issue focuses on data integrity and minimal schema changes.
Problem
Currently,
EditHabitModal.tsxallows users to freely change a habit’s name (title).This creates a data integrity issue:
A habit with existing logs should not change its meaning, only its presentation.
Goal
Preserve historical accuracy by preventing direct renaming of habits that already have logs.
Instead, when a habit has logs and the user changes its name:
Proposed Solution (Option A)
Business Rule
When logs exist and the title is changed:
UX Behavior
When the user tries to change the name of a habit with existing logs:
Modal message (example):
Actions:
Technical Notes
Location
EditHabitModal.tsxRequired Checks
Before updating the habit title:
Logic Flow
habitsNo database migrations are required.
Acceptance Criteria
Future Considerations
This approach intentionally avoids habit versioning for now.
A future improvement could introduce:
This issue focuses on data integrity and minimal schema changes.