No session, no message
I was writing into someone else's database.
I read the schema.
I understood the tables.
I made the insert.
It worked.
What I missed wasn't how to write.
It was when writing was actually possible.
In OpenCode, a message doesn't simply reference a session.
It depends on one existing first.
That's more than a foreign key.
It's a timing constraint.
There is no first message without a conversation to belong to.
Every test I ran already had a session.
Every manual switch I'd done already had a session.
The one scenario I hadn't exercised was the one every new user would hit first.
The very first switch.
That was enough.
If you're writing directly into another tool's database, don't stop after understanding the schema.
List every foreign key.
Then ask a different question.
Can this relationship be unsatisfied at the exact moment I need to write?
Those answers are where first-run bugs usually live.
The schema tells you what the data looks like.
The first run tells you whether it can exist at all.