Skip to content

Commit

Permalink
Run migration in main function
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMoolenaar committed Feb 8, 2024
1 parent d4bc519 commit 23d272e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY --from=planner /app/recipe.json recipe.json

# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
RUN cargo install sqlx-cli
# RUN cargo install sqlx-cli


# Build application
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ npm run tailwind
- [x] Use the correct http status codes in login and register
- [x] Add inline email validaton https://hypermedia.systems/hypermedia-systems/#_debouncing_our_validation_requests
- [x] Refactor into separate files for each route
- [ ] Improve code for render_html.rs
- [x] Improve code for render_html.rs
- [ ] Setup build via GH actions
- [ ] Rename to RATH stack, Rust Actix Turso Hhtmx (SQLx doesn't support Turso yet.... such a shame)
- [ ] use https://github.com/wilsonzlin/minify-html in a middleware: https://docs.rs/axum/latest/axum/middleware/fn.from_fn.html


## Handy commands
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{filters::*, render_html::SHARED_JINJA_ENV, routes::error_404::*};
use axum::{
body::Body,
http::{header, HeaderValue, Request}, Router,
http::{header, HeaderValue, Request},
Router,
};
use dotenv::dotenv;
use minijinja::{path_loader, Environment};
Expand Down Expand Up @@ -42,6 +43,10 @@ async fn main() {
.connect(&db_url)
.await
.expect("Could not connect to database");
sqlx::migrate!("./migrations")
.run(&db_pool.clone())
.await
.expect("Could not run migrations");

let session_store = PostgresStore::new(db_pool.clone());
session_store.migrate().await.expect("Could not migrate session store");
Expand Down

0 comments on commit 23d272e

Please sign in to comment.