Julio Biason
4 years ago
2 changed files with 17 additions and 3 deletions
@ -0,0 +1,5 @@ |
|||||||
|
-- Create table |
||||||
|
CREATE TABLE testing ( |
||||||
|
id TEXT PRIMARY KEY, |
||||||
|
label TEXT |
||||||
|
) |
@ -1,9 +1,18 @@ |
|||||||
use sqlx::pool::Pool; |
use sqlx::sqlite::SqliteConnectOptions; |
||||||
use sqlx::sqlite::Sqlite; |
use sqlx::sqlite::SqlitePoolOptions; |
||||||
|
|
||||||
#[tokio::main] |
#[tokio::main] |
||||||
async fn main() -> Result<(), sqlx::Error> { |
async fn main() -> Result<(), sqlx::Error> { |
||||||
let pool = Pool::<Sqlite>::connect("sqlite::memory:").await?; |
println!("Open"); |
||||||
|
let pool = SqlitePoolOptions::new() |
||||||
|
.connect_with( |
||||||
|
SqliteConnectOptions::new() |
||||||
|
.filename("testing.sqlite") |
||||||
|
.create_if_missing(true), |
||||||
|
) |
||||||
|
.await?; |
||||||
|
println!("Migrate"); |
||||||
sqlx::migrate!("db/migrations").run(&pool).await?; |
sqlx::migrate!("db/migrations").run(&pool).await?; |
||||||
|
println!("Done"); |
||||||
Ok(()) |
Ok(()) |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue