Deterministic database seeding for drizzle-rs.
Generates reproducible INSERT statements using type-aware generators and column name heuristics. FK-aware topological ordering ensures parent tables are seeded before children.
Example
#
#
Deterministic database seeding for drizzle-rs.
Generates reproducible INSERT statements using type-aware generators and column name heuristics. FK-aware topological ordering ensures parent tables are seeded before children.
# #[cfg(feature = "sqlite")]
# {
use drizzle_core::{SQLSchemaImpl, TableRef};
use drizzle_seed::SeedConfig;
struct AppSchema;
impl SQLSchemaImpl for AppSchema {
fn table_refs(&self) -> &'static [&'static TableRef] {
&[]
}
fn create_statements(&self) -> drizzle_core::error::Result<impl Iterator<Item = String>> {
Ok(std::iter::empty())
}
}
let schema = AppSchema;
let stmts = SeedConfig::sqlite(&schema)
.seed(42)
.generate();
assert!(stmts.is_empty());
// Cleanup uses the same typed config for every dialect. Execute the
// returned statements in order before generating the replacement data.
let reset = SeedConfig::sqlite(&schema).reset_plan().expect("valid reset plan");
assert!(reset.is_empty());
# }