Files
animaltrack/migrations/0009-user-defaults.sql
Petru Paler 25a91c3322 fix: remove trailing newlines from migrations to prevent SQLITE_MISUSE errors
Python's sqlite3.executescript() has a bug where trailing newlines after
the final semicolon create empty statements. When APSW's log_sqlite() is
enabled (via apswutils, imported by fastmigrate), these cause visible
"API called with NULL prepared statement" errors during interpreter shutdown.

- Strip trailing newlines from all 9 existing migration files
- Update migration template to end with semicolon, no trailing newline
- Document the requirement in CLAUDE.md

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 16:09:06 +00:00

17 lines
562 B
SQL

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