ReviewOS

also looking at this

stacks/lastsoulultra

fix(database): generate the migrations the models have been waiting for

#13
Merged glennmichael123 wants to merge fix/product-variant-columns into main
10 files +625 -10
6 days ago

Deploy has failed on every commit to main since at least 27 October, and it is not the deploy step — it is ./buddy seed during Setup Pantry:

ProductVariant: table product_variants has no column named sku
58/59 model(s) and 0/0 application seeder(s) completed, 1 failed.

product_variants was created with nine columns. The vendored model declares four more — sku, price, compare_at_price, inventory_count, all added by framework upgrades — and the seeder writes all of them, so every insert was rejected.

What this contains

./buddy generate:migrations is the documented workflow for exactly this. Diffing the models against the schema turned up nine files rather than one:

4 tables the models describe and the schema never hadcard_attachments, feedback_tokens, gdpr_requests, payment_webhook_events
3 column additionsproduct_variants (the failure), errors.resolution, payments.failure_reason
1 indexproduct_variants_product_sku_unique, which the model declares
1 rebuildstorage_item_tasks

All nine carry -- qb:generated, which is what buddy migrate's standing warning about 175 unmarked hand-written migrations has been asking for.

Why all nine rather than just the one

Applying only the product_variants alter would fix the symptom, but the model snapshot is regenerated as a whole — keeping part of the output would leave it claiming a sync that is not there, and the next generate:migrations would produce the rest anyway.

The one rebuild is the only non-additive file. It uses the standard safe SQLite pattern: copy rows into a temp table inside a transaction, PRAGMA foreign_key_check, then commit.

Verified

From an empty database, which is what the deploy does:

  • ./buddy migrate — 233 migrations applied
  • ./buddy seed — 59/59 models, nothing failed

165 tests, lint and typecheck unchanged.

🤖 Generated with Claude Code

10 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.