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(()) }