Grow Seeder CLI is a command line tool written in Rust to manage database seeders. It allows to generate, list and run seeders defined in RON format for LibSQL, PostgreSQL, MySQL and SQLite compatible databases. Automatically detects the database type through the DATABASE_URL
environment variable.
- Environment variables:
DATABASE_URL
: Database connection URL.TURSO_AUTH_TOKEN
(only for LibSQL/Turso databases).
cargo install grow-rs
# or
cargo install --git https://github.com/Wilovy09/Grow-rs
Commands | Functions |
---|---|
grow init | Creates a seeders/ folder in the current directory to store seeders. |
grow new NAME | Creates a new .ron file inside the seeders/ folder. The file name will be <NAME>.ron . |
grow list | Displays a list of all available seeders in the seeders/ folder. |
grow run NAME.ron | Run the seeder. If no file is specified, it will run all seeders in alphabetical order. |
Feature | Description |
---|---|
default |
Install libsql && sqlx databases support. |
libsql |
Install only libsql support. |
sqlx |
Install only sqlx databases support. |
A seeder file in .ron
format could have the following content:
Note
If the ID is generated automatically thanks to the db, it is not necessary to enter it in the seeder.
(
// Table name
User: [
{
"role": "Admin",
"email": "[email protected]",
"password": "hashed_password_admin",
"created_at": "2024-12-22 12:00:00",
"updated_at": "2024-12-22 12:00:00"
},
{
"role": "Client",
"email": "[email protected]",
"password": "hashed_password_client1",
"created_at": "2024-12-22 12:00:00",
"updated_at": "2024-12-22 12:00:00"
},
{
"role": "Client",
"email": "[email protected]",
"password": "hashed_password_client2",
"created_at": "2024-12-22 12:00:00",
"updated_at": "2024-12-22 12:00:00"
}
]
)
Grow Seeder CLI is compatible with:
Note
Required on all DATABASE_URL
in your .env
- LibSQL: Requires the
TURSO_AUTH_TOKEN
variable. - PostgreSQL
- MySQL
- SQLite
The CLI automatically detects the database type via DATABASE_URL
and handles the connection appropriately.
- Create a library to run seeder in the code and not with CLI
- Add cargo features to CLI.
- Add
fake
in column value to create fake data.
Example for fake
feature:
(
User: [
// The definitive form has not yet been defined
{
"role": "Admin",
"email": "fake:email",
"password": "fake:string",
"created_at": "fake:datetime",
"updated_at": "fake:datetime"
},
{
"role": "Client",
"email": Fake("email"),
"password": Fake("string"),
"created_at": Fake("datetime"),
"updated_at": Fake("datetime")
},
{
"role": "Client",
"email": "fake::email",
"password": "fake::password",
"created_at": "fake::datetime",
"updated_at": "fake::datetime"
},
]
)
This project is licensed under the MIT License.