feat: implement user defaults persistence (Step 9.3)

Add user_defaults table and repository for persisting form defaults
across sessions. Feed and egg forms now load/save user preferences.

Changes:
- Add migration 0009-user-defaults.sql with table schema
- Add UserDefault model and UserDefaultsRepository
- Integrate defaults into feed route (location, feed_type, amount)
- Integrate defaults into egg route (location)
- Add repository unit tests and route integration tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-31 14:35:27 +00:00
parent d89c46ab51
commit 719d1e6ce7
9 changed files with 566 additions and 6 deletions

View File

@@ -0,0 +1,17 @@
-- ABOUTME: Migration for user_defaults table
-- ABOUTME: Stores per-user form defaults (location, feed type, etc.) that persist across sessions
CREATE TABLE user_defaults (
username TEXT NOT NULL REFERENCES users(username),
action TEXT NOT NULL CHECK(action IN ('collect_egg','feed_given')),
location_id TEXT,
species TEXT,
animal_filter TEXT,
feed_type_code TEXT,
amount_kg INTEGER,
bag_size_kg INTEGER,
updated_at_utc INTEGER NOT NULL,
PRIMARY KEY (username, action)
);
CREATE INDEX idx_user_defaults_username ON user_defaults(username);