-- 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);
