From 7a9e14145fdedfac900c927cf8ce6302821bc8ef Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Wed, 26 May 2021 12:45:33 -0300 Subject: [PATCH] Finally creating the file --- .../db/migrations/202105261221_create_table.sql | 5 +++++ sqlxtest/src/main.rs | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 sqlxtest/db/migrations/202105261221_create_table.sql diff --git a/sqlxtest/db/migrations/202105261221_create_table.sql b/sqlxtest/db/migrations/202105261221_create_table.sql new file mode 100644 index 0000000..29e377d --- /dev/null +++ b/sqlxtest/db/migrations/202105261221_create_table.sql @@ -0,0 +1,5 @@ +-- Create table +CREATE TABLE testing ( + id TEXT PRIMARY KEY, + label TEXT +) diff --git a/sqlxtest/src/main.rs b/sqlxtest/src/main.rs index 2cc7ac2..a2f8eb7 100644 --- a/sqlxtest/src/main.rs +++ b/sqlxtest/src/main.rs @@ -1,9 +1,18 @@ -use sqlx::pool::Pool; -use sqlx::sqlite::Sqlite; +use sqlx::sqlite::SqliteConnectOptions; +use sqlx::sqlite::SqlitePoolOptions; #[tokio::main] async fn main() -> Result<(), sqlx::Error> { - let pool = Pool::::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?; + println!("Done"); Ok(()) }