Markdown Files
migs
collecting sql scripts since 2026
Usage
use migs::{migs, collect, Migs};
// Register SQL from a file (scope defaults to "init")
migs!(path = "migrations/001_init.sql");
migs!(path = "migrations/002_seed.sql", scope = "seed");
// Register literal SQL inline
migs!(sql = "CREATE TABLE users (id INT PRIMARY KEY, name TEXT)");
migs!(sql = "INSERT INTO users (id, name) VALUES (1, 'Alice')", scope = "seed");
// Collect all registered SQL scripts
let scripts: Vec<&Migs> = collect!();
// Iterate over them
for script in scripts {
println!("Scope: {}", script.scope);
println!("Source: {}", script.source);
println!("Content: {}", script.content);
// Execute the SQL script here
// TODO: Execute script.content against your database
}
Features
- Compile-time registration: SQL scripts are registered at compile time using the
migs!macro - File and inline support: Load SQL from files or use inline strings
- Scoped organization: Group migrations by scope (e.g., "init", "seed", "migrate")
- Zero runtime overhead: Uses the
inventorycrate for efficient compile-time collection
License
This project is licensed under a Non-Commercial License with Author Exceptions.
- Non-commercial use is freely permitted (personal, educational, research, etc.)
- Commercial use requires explicit permission from the author (Silen Locatelli)
- See LICENSE.md for full terms
To request a commercial use license or exception, please contact the author through the repository.