Tutorial · target: how to build api seed data workflow
How to Generate Issue tracker fixture for a drift-check walkthrough Seed Data with One Command
User wants a repeatable workflow so seed data never drifts from the API.
Direct answer
Generating a seed and a negative fixture set for Issue tracker fixture for a drift-check walkthrough takes one generate command and produces a set of committed files, with no hand-written INSERT statement in between.
The steps assume Node.js 22.6 or newer and the schema document that ships with this page; a schema with remote $ref URLs needs the files downloaded first.
One generate command writes 2 tables in dependency order into ./seed/sql/seed.sql, and the negative cases go to ./seed/sql/negatives.sql beside it; the same run also writes the pytest suite in ./seed/pytest, where each negative case is asserted against the schema keyword it breaks.
Data as of 2026-11-18 · source: 1 Stack Overflow questions, 45 Hacker News stories, ws at 1,548,120,709 monthly downloads · negative-case messages reproduced by executing the fixture against a local SQL engine (Node.js v24.22.0, engine 3.53.4) at 2026-11-18T11:53:54.233Z
Prerequisites — Issue tracker
You need a schema document for Issue tracker fixture for a drift-check walkthrough and a Node.js runtime. The Issue tracker fixture for a drift-check walkthrough fixture used here has 2 tables, and the commands below assume the file is at openapi/file that ships with this page. Nothing else is required: no database connection, no API key, no network access at generation time.
The steps
One command does the work. The generate command reads the schema, writes the seed and the negative cases in a single pass, and prints what it produced: the tables it wrote, the rows per table and the number of negative cases. For Issue tracker fixture for a drift-check walkthrough that is 2 tables in dependency order, with 12 constraints carried into the DDL. Two read-only commands sit next to it for checking instead of writing: validate reports the $ref chains that cannot be resolved and exits non-zero when one is broken, and inspect prints the tables, columns, primary keys and foreign keys the tool derived.
What you end up with
A set of committed artefacts: the PostgreSQL seed script, the negative SQL cases and the pytest suite. The seed for Issue tracker fixture for a drift-check walkthrough contains 2 table definitions and their rows in dependency order. The negative file holds the instances the API must reject, one per constraint class that the fixture declares, and the pytest suite carries both the valid rows and the negative ones. All of them are text, all of them diff in review, and all of them are regenerated by re-running the same command.
Wiring it into CI
The CI step is a diff, not a test. Regenerate the seed and fail the build if the committed file differs from the regenerated one. That single check catches the case where Issue tracker fixture for a drift-check walkthrough changed shape and the fixture did not, which is the failure that a hand-maintained seed produces silently for months.
Troubleshooting
If the generator warns about a schema it skipped, the warning names the construct. For Issue tracker fixture for a drift-check walkthrough, the constructs worth knowing about are the range declaration on issues.number and the reference from issues to projects. A skipped construct is reported, never silently dropped, which is the behaviour to insist on from any tool in this position.
| Failure class | Column | SQLSTATE | Error name | Engine message (verbatim) |
|---|---|---|---|---|
| Missing required field | projects.key | 23502 | not_null_violation | NOT NULL constraint failed: projects.key |
| Out-of-contract value | issues.number | 23514 | check_violation | CHECK constraint failed: issues_number_check |
| Dangling foreign key | issues.project_id | 23503 | foreign_key_violation | FOREIGN KEY constraint failed |
| Table | Referenced by | Written |
|---|---|---|
| projects | issues | after issues |
| issues | — | first, no dependencies |
npx --yes @wenlu8848/schemaseed generate --input ./tut_issues.openapi.yaml --out ./seed --formats sql --count 10 --seed 42
Download tut_issues.openapi.yaml
-- Generated by schemaseed.
-- seed: 42
-- rows per table: 10
-- Foreign key values are taken from the rows of the referenced table.
BEGIN;
CREATE TABLE IF NOT EXISTS "projects" (
"id" UUID,
"key" TEXT NOT NULL,
"name" TEXT NOT NULL,
CONSTRAINT "projects_pkey" PRIMARY KEY ("id")
);
CREATE TABLE IF NOT EXISTS "issues" (
"id" UUID,
"project_id" UUID NOT NULL,
"number" INTEGER NOT NULL,
"title" TEXT NOT NULL,
"state" TEXT NOT NULL,
"labels" TEXT NOT NULL,
CONSTRAINT "issues_pkey" PRIMARY KEY ("id"),
CONSTRAINT "issues_number_check" CHECK ("number" >= 1),
CONSTRAINT "issues_state_check" CHECK ("state" IN ('open', 'closed'))
);
DO $schema_seed$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'issues_project_id_fkey') THEN
ALTER TABLE "issues" ADD CONSTRAINT "issues_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects" ("id");
END IF;
END
$schema_seed$;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('f36742e7-0fc5-4661-aa4b-e6c4048b71c9', 'cedar summit', 'grove river')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('2a21671e-28f0-4316-8a82-493278bd6c2b', 'nia.grant@example.net', 'Osaka, Elm Avenue 238')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('4b809d8c-a274-4d8f-93d5-a16390ac719d', 'fable lumen', 'chen.duarte@example.net')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('61a61b0c-7a6c-4c5c-97ac-82510816457f', 'vertex fable', 'juniper bravo')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('9e3dcbcc-b2ca-4a85-9f1f-14680b6e18c1', 'vertex ember', 'Jun Lund')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('8a417343-7b31-40b4-ac72-b94e4c5b611b', 'jun.bianchi@mail.example', 'iris.petrov@example.com')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('8734da93-58d8-4e91-a545-d851ca1e77c1', 'tundra umbra', 'grove-grove-287')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('0f081199-4b62-476b-8db7-c0c99a74427a', 'Gus Engel', 'vertex-cedar-95')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('3f1a1479-a842-4f41-adea-a5aeb81f3f5f', 'Lisbon, Riverside Lane 219', 'Lisbon, Elm Avenue 227')
ON CONFLICT DO NOTHING;
INSERT INTO "projects" ("id", "key", "name")
VALUES ('da008090-b208-4976-92c7-3628b290a6d1', 'chen.moreau@test.dev', 'cedar-vertex-569')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('5c1bd0b5-c285-4045-b892-9c5b99acfb4b', '4b809d8c-a274-4d8f-93d5-a16390ac719d', 153, 'zephyr quartz', 'open', 'Quinn Kaur')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('c1994bb3-21f9-4227-88df-1a0e71659f23', '9e3dcbcc-b2ca-4a85-9f1f-14680b6e18c1', 348, 'quartz-pebble-794', 'closed', 'gus.fontaine@mail.example')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('14b4fbaf-0f12-4019-b273-1ea22c7f32e1', '8a417343-7b31-40b4-ac72-b94e4c5b611b', 656, 'Auckland, Harbor Road 65', 'open', 'grove juniper')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('8f666593-b528-4970-8eb5-9db64b1b5ef3', '4b809d8c-a274-4d8f-93d5-a16390ac719d', 674, 'Osaka, Harbor Road 114', 'open', 'Iris Ibarra')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('f0d08240-c86d-4fc9-b6ed-b7a4152c0058', '4b809d8c-a274-4d8f-93d5-a16390ac719d', 806, 'zephyr cedar', 'open', 'kelp fable')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('5361c21b-e38b-4483-afd8-425194fe21ea', '4b809d8c-a274-4d8f-93d5-a16390ac719d', 734, 'willow kelp', 'open', 'Kai Holt')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('b33fa99f-35b7-4023-9acd-ba3f281c1036', 'da008090-b208-4976-92c7-3628b290a6d1', 239, 'indigo-nimbus-446', 'closed', 'sami.adler@example.net')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('2119d123-d6ff-4b4e-bdaa-e2ab8a993430', 'da008090-b208-4976-92c7-3628b290a6d1', 967, 'fable willow', 'closed', 'tundra alpha')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('065fb0bb-b297-4ed7-904f-41910a1a73d3', 'f36742e7-0fc5-4661-aa4b-e6c4048b71c9', 728, 'Milo Holt', 'open', 'ember-lumen-722')
ON CONFLICT DO NOTHING;
INSERT INTO "issues" ("id", "project_id", "number", "title", "state", "labels")
VALUES ('ef709198-0cab-4f69-89b8-df0f08d6a06b', 'f36742e7-0fc5-4661-aa4b-e6c4048b71c9', 222, 'juniper-tundra-632', 'closed', 'Auckland, Riverside Lane 96')
ON CONFLICT DO NOTHING;
COMMIT;
Frequently asked questions
- How long does the whole workflow take?
- One generate command and a moment on the Issue tracker fixture for a drift-check walkthrough fixture of 2 tables; the slow part is deciding the row order, which is exactly what the generator removes.
- What do I commit to the repository?
- The generated files, all as text: the PostgreSQL seed script, the negative SQL cases and the pytest suite. Re-running with the same seed reproduces them byte for byte on the Issue tracker fixture for a drift-check walkthrough schema.
- Does the CI step need a database?
- The drift check does not: it regenerates and fails if the committed file differs. Add a database service only if you also load the 2 tables.
- What happens if my schema changes?
- The regenerated file differs, CI fails with the diff attached, and every declaration in the schema is re-read, so a new one appears in the negative set immediately.
Run it against your own schema
SchemaSeed is MIT licensed and free: unlimited local generation, no account, no telemetry and no usage limit. It reads your schema file on your own machine, so nothing is uploaded anywhere. If it saves you time, you can support the project.
Get SchemaSeed — free Support the project
Questions: support@schemaseed.drz8848.win