rippinrobr / barrel

πŸ›’ A database schema migration builder for Rust

Home Page:https://spacekookie.github.io/barrel/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A powerful schema migration builder, that let's you write your SQL migrations in Rust.

barrel makes writing migrations for different databases as easy as possible. It provides you with a common API over SQL, with certain features only provided for database specific implementations. This way you can focus on your Rust code, and stop worrying about SQL.

While barrel works on stable rust with most features, please note that some experimental features might require the nightly compiler.

Example

The following example will help you get started

extern crate barrel;

use barrel::*;
use barrel::backend::Pg;

fn main() {
    let mut m = Migration::new();
    m.create_table("users", |t| {
        t.add_column("name", Type::Text);
        t.add_column("age", Type::Integer);
        t.add_column("owns_plushy_sharks", Type::Boolean);
    });

    println!("{}", m.make::<Pg>());
}

If you have feedback regarding the API or things you would want barrel to do, please open an issue. And documentation PR's are always welcome πŸ’š

Using Diesel

Since diesel 1.2.0 it's possible to now use barrel for migrations with diesel. A guide with some more information on how to get started can be found here

Unstable features

Starting with v0.2.4 barrel now has an unstable feature flag which will hide features and breaking changes that are in-development at the time of a minor or patch release. You can use these features if you so desire, but be aware that their usage will change more rapidely between versions (even patches) and their usage will be badly documented.

License

barrel is free software: you can redistribute it and/or modify it under the terms of the MIT Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MIT Public License for more details.

Conduct

In the interest of fostering an open and welcoming environment, the barrel project pledges to making participation a harassment-free experience for everyone. See Code of Conduct for details. In case of violations, e-mail kookie@spacekookie.de.

About

πŸ›’ A database schema migration builder for Rust

https://spacekookie.github.io/barrel/

License:MIT License


Languages

Language:Rust 100.0%