<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: R</title>
    <description>The latest articles on DEV Community by R (@avers2050).</description>
    <link>https://dev.to/avers2050</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4172243%2F203e4df3-5519-4c52-be2c-804c3cc23d84.png</url>
      <title>DEV Community: R</title>
      <link>https://dev.to/avers2050</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/avers2050"/>
    <language>en</language>
    <item>
      <title>Your seed data is lying to you — the case for foreign-key-consistent test data</title>
      <dc:creator>R</dc:creator>
      <pubDate>Sun, 11 Oct 2026 01:23:43 +0000</pubDate>
      <link>https://dev.to/avers2050/your-seed-data-is-lying-to-you-the-case-for-foreign-key-consistent-test-data-1511</link>
      <guid>https://dev.to/avers2050/your-seed-data-is-lying-to-you-the-case-for-foreign-key-consistent-test-data-1511</guid>
      <description>&lt;p&gt;Here's a bug I've shipped more than once: tests pass locally, demo looks great,&lt;br&gt;
then something breaks the moment real relational data shows up. The culprit is&lt;br&gt;
almost always the same — &lt;strong&gt;seed data with foreign keys that don't actually&lt;br&gt;
point at anything.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The quiet problem with hand-rolled seed data
&lt;/h2&gt;

&lt;p&gt;Say you've got the classic Prisma setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;model User {
  id    Int    @id @default(autoincrement())
  email String @unique
  posts Post[]
}

model Post {
  id       String @id @default(uuid())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you fake seed data for &lt;code&gt;Post&lt;/code&gt;, what goes in &lt;code&gt;authorId&lt;/code&gt;? If you're using a&lt;br&gt;
generic faker-style approach, you get a random integer. It &lt;em&gt;looks&lt;/em&gt; fine in a&lt;br&gt;
JSON preview. But:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;JOIN&lt;/code&gt; between &lt;code&gt;Post&lt;/code&gt; and &lt;code&gt;User&lt;/code&gt; returns rows that shouldn't exist, or none at all.&lt;/li&gt;
&lt;li&gt;A real FK constraint in Postgres rejects the insert outright (&lt;code&gt;violates foreign key constraint&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Any UI that renders "post by author" either crashes or shows ghosts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your seed data passed the eyeball test and failed the only test that matters:&lt;br&gt;
does it behave like real data?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why "just use faker" isn't enough
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;faker&lt;/code&gt; (and the dozens of wrappers around it) are great at generating &lt;em&gt;values&lt;/em&gt; —&lt;br&gt;
names, emails, prices. What they don't understand is &lt;em&gt;relationships&lt;/em&gt;. They'll&lt;br&gt;
happily put &lt;code&gt;authorId: 8471&lt;/code&gt; on a post when no user &lt;code&gt;8471&lt;/code&gt; exists, because they&lt;br&gt;
generate each field in isolation. The value is realistic; the relationship is&lt;br&gt;
fiction.&lt;/p&gt;

&lt;p&gt;To generate honest relational data you need to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generate the parent rows first (&lt;code&gt;User&lt;/code&gt;), and remember their real ids.&lt;/li&gt;
&lt;li&gt;Generate the child rows (&lt;code&gt;Post&lt;/code&gt;), and set each &lt;code&gt;authorId&lt;/code&gt; to an id that was
&lt;em&gt;actually&lt;/em&gt; generated for a user.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's not hard conceptually — it's just annoying to do by hand every single time&lt;br&gt;
you touch the schema, which is exactly why people skip it and ship dangling keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automating it
&lt;/h2&gt;

&lt;p&gt;I got tired of writing this glue, so I built a small VS Code extension,&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=Avers.seedforge" rel="noopener noreferrer"&gt;SeedForge&lt;/a&gt;,&lt;br&gt;
that reads your &lt;code&gt;schema.prisma&lt;/code&gt; and generates the data for you. The free&lt;br&gt;
edition handles single-table generation with realistic typed values and exports&lt;br&gt;
to JSON / SQL / CSV. The part relevant to this post — generating related tables&lt;br&gt;
so the child's FK column points at a real generated parent — is what I spent the&lt;br&gt;
most time getting right, because it's the thing generic tools skip.&lt;/p&gt;

&lt;p&gt;It's also on &lt;a href="https://open-vsx.org/extension/Avers/seedforge" rel="noopener noreferrer"&gt;Open VSX&lt;/a&gt; if you're&lt;br&gt;
on Cursor / VSCodium.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway, tool or no tool
&lt;/h2&gt;

&lt;p&gt;Even if you never touch SeedForge: next time you write seed data, ask whether&lt;br&gt;
your foreign keys reference rows that exist. If they don't, your tests are&lt;br&gt;
rehearsing against a world that can't happen in production. Generate parents&lt;br&gt;
first, reuse their real ids for children, and your &lt;code&gt;JOIN&lt;/code&gt;s will finally tell&lt;br&gt;
you the truth.&lt;/p&gt;

&lt;p&gt;What's your approach to relational test data — hand-written factories, SQL&lt;br&gt;
fixtures, something else? Genuinely curious what's working for people.&lt;/p&gt;

</description>
      <category>prisma</category>
      <category>testing</category>
      <category>database</category>
      <category>webdev</category>
    </item>
    <item>
      <title>I got tired of hand-writing fake data for Prisma, so I built a VS Code extension that does it from your schema</title>
      <dc:creator>R</dc:creator>
      <pubDate>Fri, 09 Oct 2026 00:27:19 +0000</pubDate>
      <link>https://dev.to/avers2050/i-got-tired-of-hand-writing-fake-data-for-prisma-so-i-built-a-vs-code-extension-that-does-it-from-5gbc</link>
      <guid>https://dev.to/avers2050/i-got-tired-of-hand-writing-fake-data-for-prisma-so-i-built-a-vs-code-extension-that-does-it-from-5gbc</guid>
      <description>&lt;p&gt;Every new table meant the same ritual: open a seed script, hand-write fake&lt;br&gt;
rows, remember which columns need to stay unique, make sure foreign keys&lt;br&gt;
actually point at something that exists. Small thing, but it adds up every&lt;br&gt;
single time you touch the schema.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;SeedForge&lt;/strong&gt; — a VS Code extension that reads your&lt;br&gt;
&lt;code&gt;schema.prisma&lt;/code&gt;, figures out sensible fake values per column (emails look&lt;br&gt;
like emails, booleans respect their defaults, enums actually vary instead of&lt;br&gt;
collapsing to one value), and writes the result straight to a file.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does (free)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Parses your Prisma schema — models, scalars, enums, &lt;code&gt;@default&lt;/code&gt;, optional
fields, arrays.&lt;/li&gt;
&lt;li&gt;Generates realistic values via &lt;code&gt;@faker-js/faker&lt;/code&gt;, with light heuristics
based on column names.&lt;/li&gt;
&lt;li&gt;Exports to &lt;strong&gt;JSON&lt;/strong&gt;, &lt;strong&gt;SQL INSERT&lt;/strong&gt;, or &lt;strong&gt;CSV&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Fully local. No account, no telemetry, no network calls.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to use it
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open a folder with a &lt;code&gt;schema.prisma&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Cmd/Ctrl+Shift+P&lt;/code&gt; → &lt;strong&gt;SeedForge: Generate Seed Data&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Pick a model, pick a row count, pick a format. Done.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's free on the VS Code Marketplace:&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=Avers.seedforge" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=Avers.seedforge&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Would genuinely like feedback — especially from anyone whose schemas have&lt;br&gt;
gnarly relation chains. That's the part I'm working on next (generating&lt;br&gt;
correctly-linked parent/child rows in one pass).&lt;/p&gt;

</description>
      <category>prisma</category>
      <category>vscode</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
