Skip to content

Commit ac6e592

Browse files
feat: add structured database seeding with YAML/JSON schema and tracking table (#14)
* feat: add structured database seeding with YAML/JSON schema and tracking table. Replaces shell-out seed with declarative YAML/JSON spec files. Supports PostgreSQL, MySQL, SQLite, tracking table, auto-generated IDs, cross-table references, unique key detection, reset mode, transactions, env var substitution, and ordered seed sets. Includes docs/seeding.md, example specs, 30+ unit tests. Closes #12
1 parent 66728a3 commit ac6e592

17 files changed

Lines changed: 4100 additions & 144 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
target/
33
bin/
44
CLAUDE.md
5+
.output.txt

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
- Seed executor tests now verify data actually arrived in the database after execution, using file-based SQLite and post-execution queries to assert row counts, column values, cross-table references, env substitution, ordering, and edge cases
12+
13+
### Fixed
14+
- Fixed clippy `collapsible_if` lint in seed executor's unique key check
15+
- Removed dead code: unused `src/cmd/seed.rs` module (replaced by `src/seed/`)
16+
- Suppressed unused field warning on `AutoIdConfig.id_type` (reserved for future use)
17+
- Removed unused imports (`Arc`, `Mutex`) and unused mutable binding in seed executor tests
18+
19+
### Added
20+
- Structured database seeding via `seed` subcommand with YAML/JSON spec files
21+
- Seed tracking table (`initium_seed` by default) for idempotent seed application
22+
- Support for PostgreSQL, MySQL, and SQLite database drivers
23+
- Auto-generated IDs and cross-table references via `_ref` / `@ref:` syntax
24+
- Environment variable substitution in seed values via `$env:VAR_NAME`
25+
- Unique key detection to prevent duplicate row insertion
26+
- Reset mode (`--reset`) to delete existing data and re-apply seeds
27+
- Transaction safety: each seed set is applied atomically with rollback on failure
28+
- Ordered seed sets and tables via `order` field
29+
- Documentation: `docs/seeding.md` with full schema reference, Kubernetes usage (env vars and volume-mounted secrets), and failure modes
30+
- Example seed specs: `examples/seed/basic-seed.yaml`, `examples/seed/sqlite-seed.yaml`, `examples/seed/env-credentials-seed.yaml`
31+
- Unit tests for seed schema parsing, database operations, executor logic, references, idempotency, reset, and edge cases
32+
1033
### Changed
1134
- Complete rewrite from Go to Rust for ~76% smaller Docker images (7.4MB → 1.8MB)
1235
- CLI framework changed from cobra to clap

0 commit comments

Comments
 (0)