What Happened
The golden-press service (Go) was rated 75% complete and appeared production-ready. Deep source analysis revealed thegolden_tickets table schema in migration 000001 didn’t match the code in repository.go:
- Migration:
holder_user_id,holder_github,verify_run_sha(9 columns) - Code:
user_id,github_identity,display_name,avatar_url,merkle_proof,status,idempotency_key(18 columns) - Missing table:
antigaming_violations(referenced in SQL queries but never created)
Key Insight
Schema drift happens when architecture and implementation are written in different sessions. The initial migration reflected the architecture spec (SRS-002). The service code reflected the implementation spec (with additional fields for display, idempotency, and integrations). Neither session verified the other.Prevention Pattern
After any session that touches bothinternal/storage/ and infrastructure/migrations/:
- Extract column names from INSERT/SELECT SQL in Go code
- Extract column names from CREATE TABLE in migrations
- Diff the two lists
- Create alignment migration if they diverge
Resolution
Created migration 000007 that:- Renamed 4 columns (
ALTER TABLE RENAME COLUMN) - Added 9 new columns with defaults then dropped defaults
- Added CHECK constraint for status enum
- Created the missing
antigaming_violationstable with indexes