Code Room
Vibe codingHard
Question
You asked an AI agent for a Postgres migration to add a non-null `tenant_id` to the `events` table (≈ 1.2 billion rows, 40k writes/sec) and backfill it. It produced this. The staging run (200k rows) finished in 3 seconds.
BEGIN;ALTER TABLE events ADD COLUMN tenant_id bigint NOT NULL DEFAULT 0;UPDATE events SET tenant_id = lookup_tenant(account_id);ALTER TABLE events ALTER COLUMN tenant_id DROP DEFAULT;ALTER TABLE events ADD CONSTRAINT fk_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id);COMMIT;What happens when this runs in production, and how do you rewrite the rollout?
What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.