refinery/
lib.rs

1/*!
2Powerful SQL migration toolkit for Rust.
3
4`refinery` makes running migrations for different databases as easy as possible.
5It works by running your migrations on a provided database connection, either by embedding them on your Rust code, or via `refinery_cli`.\
6Currently, [`Postgres`](https://crates.io/crates/postgres), [`Rusqlite`](https://crates.io/crates/rusqlite), and [`Mysql`](https://crates.io/crates/mysql) are supported.\
7
8`refinery` works best with [`Barrel`](https://crates.io/crates/barrel) but you can also have your migrations on .sql files or use any other Rust crate for schema generation.
9
10## Usage
11
12- Migrations can be defined in .sql files or Rust modules that must have a function called `migration()` that returns a [`std::string::String`]
13- Migrations, both .sql files and Rust modules must be named in the format `V{1}__{2}.rs ` where `{1}` represents the migration version and `{2}` the name.
14- Migrations can be run either by embedding them on your Rust code with [`embed_migrations!`] macro, or via `refinery_cli`.
15
16[`embed_migrations!`]: macro.embed_migrations.html
17
18### Example
19```rust,ignore
20use rusqlite::Connection;
21
22mod embedded {
23    use refinery::embed_migrations;
24    embed_migrations!("./tests/sql_migrations");
25}
26
27let mut conn = Connection::open_in_memory().unwrap();
28embedded::migrations::runner().run(&mut conn).unwrap();
29```
30
31for more examples refer to the [examples](https://github.com/rust-db/refinery/tree/master/examples)
32*/
33
34pub use refinery_core::config;
35pub use refinery_core::{
36    error, load_sql_migrations, Error, Migration, Report, Runner, SchemaVersion, Target,
37};
38#[doc(hidden)]
39pub use refinery_core::{AsyncMigrate, Migrate};
40pub use refinery_macros::embed_migrations;