Skip to content

Show how to load optional development seed data - #462

Merged
jxs merged 1 commit into
rust-db:mainfrom
rayw-lab:codex/optional-development-seed-data
Nov 27, 2026
Merged

jxs merged 1 commit into
rust-db:mainfrom
rayw-lab:codex/optional-development-seed-data

Conversation

@rayw-lab

Copy link
Copy Markdown
Contributor

Summary

Add a runnable SQLite example for projects that use the same schema migrations in every environment and load sample rows only in development. The example runs the migrations first, then inserts a demo project when --seed is supplied. A conflict on the project's slug leaves an existing row in place, including any local edits.

Refs #384.

Try it out

db_dir=$(mktemp -d)
cargo run -p refinery-examples --example seed_data -- "$db_dir/demo.db"
cargo run -p refinery-examples --example seed_data -- "$db_dir/demo.db" --seed
cargo run -p refinery-examples --example seed_data -- "$db_dir/demo.db" --seed

Tests

I ran the three commands against the same fresh SQLite database and got 0, 1, and 1 rows. I edited the seeded row, ran the seed step again, and confirmed that the edit survived and the migration history still contained one entry.

I built the SQLite CLI with cargo +stable build --locked -p refinery_cli --no-default-features --features sqlite, put it on my path, and ran cargo +stable test --locked -p refinery --features rusqlite --test rusqlite. All 28 tests passed.

I carefully reviewed the diff and the test results before opening this PR.

@jxs jxs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jxs
jxs merged commit 6a4d4d7 into rust-db:main Nov 27, 2026
29 of 30 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.

2 participants