GithubHelp home page GithubHelp logo

prisma / barrel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rust-db/barrel

2.0 2.0 1.0 10.46 MB

๐Ÿ›ข A database schema migration builder for Rust

Home Page: https://rust-db.github.io/barrel/

License: MIT License

Rust 99.84% Nix 0.16%

barrel's Introduction

A powerful database schema builder, that lets you write your SQL migrations in Rust!

barrel offers callback-style builder functions for SQL migrations and is designed to be flexible, portable and fun to use. It provides you with a common interface over SQL, with additional database-specific builders.

This way you can focus on your Rust code, without having to worry about SQL.

Example

The following example will help you get started

use barrel::{types, Migration};
use barrel::backend::Pg;

fn main() {
    let mut m = Migration::new();

    m.create_table("users", |t| {
        t.add_column("name", types::varchar(255));
        t.add_column("age", types::integer());
        t.add_column("owns_plushy_sharks", types::boolean());
    });

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

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

Migration guide

If you've been using barrel to write migrations for diesel before the 0.5.0 release, some migration of your migrations will be required. Since 0.5.0 the way types are constructed changed. Instead of constructing a type with Types::VarChar(255) (an enum variant), the types are now provided by a module called types and builder functions. The same type would now be types::varchar(255) (a function call), which then returns a Type enum.

You can also directly created your own Type builders this way. Check the docs for details!

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 [email protected].

barrel's People

Contributors

aknuds1 avatar eld avatar endocrimes avatar gabisurita avatar jasonmiesionczek avatar jlegrone avatar jp-pulga avatar madao-3 avatar mikong avatar paolobarbolini avatar rippinrobr avatar spacekookie avatar sww13 avatar tmcw avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.