Home Generate a SQL seed, then verify the database
Generate a SQL seed, then verify the database
Use a small table to check names, types and import behavior before creating a larger development dataset. Generated DDL is a starting point for a disposable test schema.
Try the reviewed example
Open this exact schema in the generator
These are synthetic examples. Record the engine version, schema and seed together. Checksums and row counts are in the example manifest. Review the output before importing it into a disposable test environment.
Watch the browser workflow
Silent walkthrough: open the saved schema, inspect its fields, choose the output format and start the download. The recording demonstrates browser generation and export; follow the written instructions below for the application or database steps.
Start with a table whose contract is obvious
Create demo_users with a numeric id, a name and an email. In the browser SQL generator, select the database dialect and inspect a three-row preview. To reproduce the example from a repository checkout, follow the CLI setup and run:
node cli/bin/fundata.js generate --field id:row_number --field name:full_name --field email:email_address --rows 3 --seed db-demo-v1 --format sql --table demo_users --dialect postgres --create --out seed-postgres.sql node cli/bin/fundata.js generate --field id:row_number --field name:full_name --field email:email_address --rows 3 --seed db-demo-v1 --format sql --table demo_users --dialect mysql --create --out seed-mysql.sql
The dialect option controls SQL identifier quoting. Inspect the SQL against your database version and application schema; it is not a migration generator and does not infer your indexes, foreign keys or business constraints.
Load a disposable database and count the result
The following import commands require PostgreSQL or MySQL client tools and an existing disposable database named fundata_demo. Create that database using your usual local database workflow first. Execute only the block for your database, and review the generated SQL before loading it.
psql -d fundata_demo -v ON_ERROR_STOP=1 -f seed-postgres.sql psql -d fundata_demo -c 'SELECT COUNT(*) FROM demo_users;'
mysql -u root -p fundata_demo --execute="source seed-mysql.sql" mysql -u root -p fundata_demo --execute="SELECT COUNT(*) FROM demo_users;"
The expected count for a fresh table is three. Re-running an INSERT file can add duplicates, and re-running its CREATE TABLE can fail because the table already exists. Use an isolated test database and your project's explicit reset strategy rather than treating the file as an idempotent migration.
Existing tables and related records need different checks
For an existing table, omit --create and align every generated field with an actual column. Verify required values, lengths, precision and allowed status values. For related tables, prepare parent IDs first, reuse those values for child references and import in dependency order. Generating two unrelated UUID columns does not create a relationship.
Before expanding row counts, verify a known parent-child join and a constraint failure case. Consult the dedicated PostgreSQL, MySQL and database test-data guides for format and workflow details.
Keep a seed manifest with the file
Store the generated SQL with its schema export, seed, dialect and repository revision. A built-in template can contain date bounds that depend on the current date; export the schema and fix those bounds before relying on regeneration across days. Use a reviewed fixture when exact historical bytes matter.
After a small import succeeds, increase the row count to the scale your test needs. The CLI accepts up to 100,000 rows per generation. Create a browser SQL seed, or convert an existing file with CSV to SQL or JSON to SQL.
Last updated