Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blog): add missing sqlx migration code to auth blog post #408

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions www/_blog/2022-08-11-authentication-tutorial.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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(shuttle_service::error::CustomError::new)?;

let router = Router::new()
.route("/", get(index))
.route("/styles.css", get(styles))
Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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()
// ...
Expand Down