New on the blog: Seeding Your Database the Idempot...
# wheels-dev
p
New on the blog: Seeding Your Database the Idempotent Way. <https://blog.wheels.dev/posts/idempotent-database-seeding/> What it covers: •
seedOnce()
— the idempotent seed helper. Create a row only if a matching one doesn't already exist; safe to run a hundred times. • The file convention:
app/db/seeds.cfm
(runs in every environment) then
app/db/seeds/<env>.cfm
(env-specific, sibling directory — NOT a hyphenated suffix). • Why the whole run is one transaction that rolls back on ANY validation failure (#2973) — a half-applied seed run must never look fully-applied. • Composite uniqueness, seeding from code via
application.wheels.seeder
, and the CLI:
wheels seed
, scaffold with
wheels generate snippets seed-data
. • Sharp edges: it's a skip not an upsert,
--generate
is random non-idempotent junk, and
wheels db:seed
/
wheels generate seed
are not real commands.