aboutsummaryrefslogtreecommitdiff
path: root/development/libs/barrel/examples/user_index.rs
blob: f2fe6619184d129a200ad450618d914d96aa7970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use barrel::{types, Migration};

fn main() {
    let mut m = Migration::new();
    m.create_table("users", |t| {
        t.add_column("first_name", types::varchar(64).nullable(false));
        t.add_column("last_name", types::varchar(64).nullable(false));
        t.add_column("birthday", types::date().nullable(false));

        t.add_index(
            "names",
            types::index(vec!["first_name", "last_name"])
                .unique(true)
                .nullable(false),
        );
    });
}