Repository navigation
feat: reference categories from tasks by ID - #35
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tasks now point at a category entity by
categoryIdinstead of storing a free-textcategoryname (ADR 0001). Renaming a category becomes a single write, and every task shows the new name.categoryId: string | null, wherenullmeans Uncategorised. It's a UI label, not a stored category.null, and defaults tonullwhen omitted.Changes
category: string→categoryId: string | null. The old trim and length rules are removed, since an ID isn't typed by a person.categoryIdas given. The stores stay independent of each other: checking that the category exists is the API route's job.POST /api/taskscategoryIdisn'tnull, the route checks that the category exists. An unknown ID → 400Category not found.(the request body refers to something invalid; the endpoint itself exists).nullID, or one with no matching category, shows Uncategorised.Data: reset, not migrated
Existing Firestore task documents store
categoryand have nocategoryId. They would fail validation on read. Production only holds test data, so I'll delete thetaskscollection straight after merging rather than write a migration.Known gap
The route checks the category, then creates the task, in two separate steps. A category deleted in between would leave a task pointing at nothing. The list handles this safely by showing Uncategorised. Step 8 closes the gap with a transaction when category delete moves tasks to Uncategorised.
Testing
categoryId, so a store that dropped the field would fail.categoryIdleft out →null;Not in this PR