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>
18 lines
749 B
SQL
18 lines
749 B
SQL
-- ABOUTME: Migration to create feed_inventory table.
|
|
-- ABOUTME: Tracks feed purchases, amounts given, and current balance.
|
|
|
|
-- Feed inventory tracks global feed levels per type
|
|
-- Stores amounts in kg, prices in cents
|
|
CREATE TABLE feed_inventory (
|
|
feed_type_code TEXT PRIMARY KEY REFERENCES feed_types(code),
|
|
purchased_kg INTEGER NOT NULL DEFAULT 0,
|
|
given_kg INTEGER NOT NULL DEFAULT 0,
|
|
balance_kg INTEGER NOT NULL DEFAULT 0,
|
|
last_purchase_price_per_kg_cents INTEGER,
|
|
last_purchase_at_utc INTEGER,
|
|
last_given_at_utc INTEGER,
|
|
updated_at_utc INTEGER NOT NULL
|
|
);
|
|
|
|
-- Index for finding when last purchase/given occurred
|
|
CREATE INDEX idx_feed_inventory_last_on ON feed_inventory(last_purchase_at_utc, last_given_at_utc); |