Skip to content

fix(seed): handle finite FK generation feedback#37

Merged
machado144 merged 2 commits into
mainfrom
fix/serve-seed-feedback
Jun 16, 2026
Merged

fix(seed): handle finite FK generation feedback#37
machado144 merged 2 commits into
mainfrom
fix/serve-seed-feedback

Conversation

@machado144

@machado144 machado144 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • allow tables without primary keys to generate multiple rows without false uniqueness collisions
  • deterministically enumerate finite FK primary-key combinations for identifying and many-to-many tables, then surface capped row counts as warnings
  • preserve exact column DDL types and cap generated string values to declared char/varchar lengths
  • map MySQL bit columns to boolean-safe generated values and cover the insert path in integration tests
  • let strict temporal/boolean/json DB types override semantic name guesses, and map generic temporal names to date/time fakers
  • add concise serve UI feedback for schema graph loading and clone-schema phases/progress

Generate values that fit the column type & constraints

  • temporal primary-key columns get a real date/time/datetime instead of a sequential integer (a DATE in a composite PK was seeded as 1Incorrect date value)
  • UNIQUE numeric/temporal columns get a collision-free monotonic sequence — the numeric analog of uuid. They previously got a uuid string a numeric column can't store (Data truncated), or a random number() that collides at high row counts (Duplicate entry)
  • decimal/numeric generators are sized to the declared precision/scale: scale-0 columns get integers, and small-precision columns (e.g. decimal(3,2)) are bounded so values never exceed the column (Out of range value)
  • README + docs/schema.md mapping rules updated to match

Serve UI

  • stream per-table progress during the truncate phase, mirroring the insert phase (no more frozen "Truncating tables" on large schemas). MySQL truncates per table so progress is genuine; PostgreSQL clears atomically and reports completion

Tests (TDD: reproduced before fixing)

  • failing-first unit tests in internal/faker for every mapping/PK path, plus money-type, precision-bounded decimal, and a 5000-row unique-sequence no-collision check
  • generic regression tables in the integration schema (Postgres + MySQL): unique numeric + zero-scale/small-precision decimals, single-column and composite temporal primary keys; a 2000-row UNIQUE-numeric insert reproducing the duplicate-key failure; and per-table truncate-progress assertions
  • DDL uses only universally-supported features, so the matrix (PG 13/15/17 × MySQL 5.7/8.0/8.4) all pass

Tests

  • go test ./internal/... → 437 pass
  • cd integration && go test -tags integration -count=1 ./... → pass on Postgres + MySQL
  • go build ./...

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

StructLint — All checks passed

168 rules validated against .structlint.yaml. No violations found.

View full run · Powered by StructLint

@machado144 machado144 force-pushed the fix/serve-seed-feedback branch 3 times, most recently from ff48cbe to 5f24e38 Compare June 15, 2026 22:00
@machado144 machado144 force-pushed the fix/serve-seed-feedback branch 3 times, most recently from 6d6f95e to d1add2b Compare June 16, 2026 06:23
…ress

Faker mapping/generation:
- temporal primary-key columns get a real date/time/datetime instead of a
  sequential integer (a DATE in a composite PK was seeded as "1")
- UNIQUE numeric/temporal columns get a collision-free monotonic sequence (the
  numeric analog of uuid) — they previously got a uuid string a numeric column
  can't store ("Data truncated"), or a random number that collides at high row
  counts ("Duplicate entry")
- decimal/numeric generators are sized to the declared precision/scale: scale-0
  columns get integers, small-precision columns are bounded so values never
  exceed the column ("Out of range value")

Serve UI:
- stream per-table progress during truncate, mirroring the insert phase

Tests/docs:
- unit + integration coverage (Postgres & MySQL) for temporal PKs, unique
  numeric/temporal columns at volume, precision-bounded fixed-point, and
  per-table truncate progress
- README and docs/schema.md updated
@machado144 machado144 force-pushed the fix/serve-seed-feedback branch from d1add2b to e2f2f29 Compare June 16, 2026 06:32
@machado144 machado144 merged commit aa7354f into main Jun 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant