feat: add barrel
This commit is contained in:
14
__database/barrel/Cargo.lock
generated
Normal file
14
__database/barrel/Cargo.lock
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "barrel"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"barrel 0.6.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "barrel"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d67c978b1322c8031145b1f6c236fc371292f52c565bc96018b2971afcbffe1"
|
||||
11
__database/barrel/Cargo.toml
Normal file
11
__database/barrel/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "barrel"
|
||||
version = "0.1.0"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
barrel = { version = "0.6.5", features = [ "pg", "mysql", "sqlite3" ] }
|
||||
|
||||
19
__database/barrel/src/main.rs
Normal file
19
__database/barrel/src/main.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use barrel::{types, Migration};
|
||||
use barrel::backend::Pg;
|
||||
use barrel::backend::MySql;
|
||||
use barrel::backend::Sqlite;
|
||||
|
||||
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().nullable(true));
|
||||
t.add_column("owns_plushy_sharks", types::boolean().nullable(true));
|
||||
});
|
||||
|
||||
println!("{}", m.make::<Pg>());
|
||||
println!("{}", m.make::<MySql>());
|
||||
println!("{}", m.make::<Sqlite>());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user