From 30473344afdc8eb0baef2f914f90f52d69afcf8f Mon Sep 17 00:00:00 2001 From: Nicole Tietz-Sokolskaya Date: Wed, 5 Jun 2024 20:54:06 -0400 Subject: [PATCH] Fix slop in DB code. Removed extraneous embedded migrations, added explicit relative path to migrations folder, removed hardcoded folder in diesel.toml --- diesel.toml | 2 +- src/db.rs | 2 +- src/server.rs | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/diesel.toml b/diesel.toml index be78c73..83d15a9 100644 --- a/diesel.toml +++ b/diesel.toml @@ -6,4 +6,4 @@ file = "src/schema.rs" custom_type_derives = ["diesel::query_builder::QueryId", "Clone"] [migrations_directory] -dir = "/home/nicole/Code/pique/migrations" +dir = "./migrations" diff --git a/src/db.rs b/src/db.rs index cc8dce6..4b4305b 100644 --- a/src/db.rs +++ b/src/db.rs @@ -3,7 +3,7 @@ use diesel::r2d2::{ConnectionManager, Pool}; use diesel::SqliteConnection; use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness}; -pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!(); +pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("./migrations/"); /// Establishes a connection to the database using the given URL. /// diff --git a/src/server.rs b/src/server.rs index 490c518..fec9cd5 100644 --- a/src/server.rs +++ b/src/server.rs @@ -5,7 +5,6 @@ use axum::routing::{get, post}; use axum::Router; use axum_login::AuthManagerLayerBuilder; use clap::Parser; -use diesel_migrations::{embed_migrations, EmbeddedMigrations}; use tower_http::services::ServeDir; use tower_http::trace::{DefaultOnRequest, DefaultOnResponse, TraceLayer}; use tower_sessions::SessionManagerLayer; @@ -27,8 +26,6 @@ use crate::logging::setup_logging; use crate::provider::Provider; use crate::templates::make_template_loader; -pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("./migrations/"); - pub async fn run() -> Result<()> { dotenvy::dotenv()?; setup_logging();