My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/development/libs/barrel/examples/sqlite_strings.rs

17 lines
676 B

use barrel::backend::Sqlite;
use barrel::{types, Migration, Table};
fn main() {
let mut m = Migration::new();
m.create_table("users", |t: &mut Table| {
t.add_column("id", types::text().primary(true));
t.add_column("name", types::varchar(255).default("Anonymous")); // Default name is "Anonymous"
t.add_column("description", types::text().nullable(true)); // Can be null
t.add_column("age", types::integer());
t.add_column("posts", types::foreign("posts", "id"));
t.add_column("created_at", types::date());
t.add_column("owns_plushy_sharks", types::boolean());
});
println!("{}", m.make::<Sqlite>());
}