Crates.io | rocket_sqlx_migrator |
lib.rs | rocket_sqlx_migrator |
version | 0.2.0 |
source | src |
created_at | 2024-06-22 17:24:42.934287 |
updated_at | 2024-06-22 17:24:42.934287 |
description | This crate works with the `rocket` web framework and `rocket_db_pools` to automatically run migrations on startup using a faring and some generic type magic. |
homepage | https://greensiren.co.uk/rocket_sqlx_migrator |
repository | https://gitlab.com/RuboGubo/rocket_sqlx_migrator |
max_upload_size | |
id | 1280592 |
size | 6,039 |
Use this crate with the rocket
web framework and rocket_db_pools
to automatically run migrations on startup using a faring and some generic type magic.
All you have to do is define a db type using rocket_db_pools
:
#[derive(Database)]
#[database("times")]
struct MainDB(Pool<Sqlite>);
and then register it to the migrator using:
#[launch]
fn rocket() -> _ {
rocket::build()
.attach(MainDB::init())
.attach(SqlxMigrator::<MainDB>::migrate())
}
Note: You can't currently change the migrations folder away from the default, found at ./migrations
.
FWI: I'm looking for some help to create some tests!
Note2myself: use cargo readme to generate readme