From 5be335671175f7b320bff98cee3a4df8591e6016 Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Tue, 18 Oct 2022 18:11:37 +0200 Subject: [PATCH 1/2] feat(blog): add missing sqlx migration code --- www/_blog/2022-08-11-authentication-tutorial.mdx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/www/_blog/2022-08-11-authentication-tutorial.mdx b/www/_blog/2022-08-11-authentication-tutorial.mdx index c07dc31a4..7746f2662 100644 --- a/www/_blog/2022-08-11-authentication-tutorial.mdx +++ b/www/_blog/2022-08-11-authentication-tutorial.mdx @@ -194,6 +194,11 @@ async fn axum( ) -> ShuttleAxum { // Build tera as before + // Run the schema.sql migration with sqlx to create our users table + pool.execute(include_str!("../schema.sql")) + .await + .map_err(CustomError::new)?; + let router = Router::new() .route("/", get(index)) .route("/styles.css", get(styles)) @@ -361,7 +366,7 @@ To initialize the random generator we use [SeedableRng::from_seed](https://docs. async fn axum( #[shuttle_shared_db::Postgres] pool: Database ) -> ShuttleAxum { - // Build tera as before + // Build tera and migrate database as before let random = ChaCha8Rng::seed_from_u64(OsRng.next_u64()) @@ -539,7 +544,7 @@ We can add the middleware to our chain using: async fn axum( #[shuttle_shared_db::Postgres] pool: Database ) -> ShuttleAxum { - // tera and random creation as before + // tera,random creation and db migration as before let middleware_database = database.clone(); @@ -652,7 +657,7 @@ Then we refer back to the [signup section](#using-html-forms) and replicate the async fn axum( #[shuttle_shared_db::Postgres] pool: Database ) -> ShuttleAxum { - // tera, middleware and random creation as before + // tera, middleware, random creation and db migration as before let router = Router::new() // ... From 17c77d44f4e9dc1288fe1404985b085419472e9f Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Tue, 18 Oct 2022 18:14:37 +0200 Subject: [PATCH 2/2] fix: nit --- www/_blog/2022-08-11-authentication-tutorial.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/_blog/2022-08-11-authentication-tutorial.mdx b/www/_blog/2022-08-11-authentication-tutorial.mdx index 7746f2662..69b626b95 100644 --- a/www/_blog/2022-08-11-authentication-tutorial.mdx +++ b/www/_blog/2022-08-11-authentication-tutorial.mdx @@ -197,7 +197,7 @@ async fn axum( // Run the schema.sql migration with sqlx to create our users table pool.execute(include_str!("../schema.sql")) .await - .map_err(CustomError::new)?; + .map_err(shuttle_service::error::CustomError::new)?; let router = Router::new() .route("/", get(index))