Move database to util
This commit is contained in:
@ -7,7 +7,7 @@ use cfg_if::cfg_if;
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use leptos::server_fn::error::NoCustomError;
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ use cfg_if::cfg_if;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
use diesel::prelude::*;
|
||||
use chrono::NaiveDate;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use crate::songdata::SongData;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
use diesel::prelude::*;
|
||||
use std::collections::HashMap;
|
||||
use server_fn::error::NoCustomError;
|
||||
|
@ -8,7 +8,7 @@ use cfg_if::cfg_if;
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use leptos::server_fn::error::NoCustomError;
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
use crate::auth::get_user;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ cfg_if! {
|
||||
use crate::auth::get_user;
|
||||
use server_fn::error::NoCustomError;
|
||||
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
use diesel::prelude::*;
|
||||
use diesel::dsl::count;
|
||||
use crate::models::*;
|
||||
|
@ -8,7 +8,7 @@ use crate::songdata::SongData;
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use leptos::server_fn::error::NoCustomError;
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
use crate::auth::get_user;
|
||||
use crate::models::{Song, Album, Artist};
|
||||
use diesel::prelude::*;
|
||||
|
@ -5,7 +5,6 @@ pub mod albumdata;
|
||||
pub mod artistdata;
|
||||
pub mod playstatus;
|
||||
pub mod playbar;
|
||||
pub mod database;
|
||||
pub mod queue;
|
||||
pub mod song;
|
||||
pub mod models;
|
||||
|
@ -37,7 +37,7 @@ async fn main() {
|
||||
debug!("Running database migrations...");
|
||||
|
||||
// Bring the database up to date
|
||||
libretunes::database::migrate();
|
||||
libretunes::util::database::migrate();
|
||||
|
||||
debug!("Connecting to Redis...");
|
||||
|
||||
|
@ -6,7 +6,7 @@ use cfg_if::cfg_if;
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use diesel::prelude::*;
|
||||
use crate::database::*;
|
||||
use crate::util::database::*;
|
||||
use std::error::Error;
|
||||
use crate::songdata::SongData;
|
||||
use crate::albumdata::AlbumData;
|
||||
|
@ -10,7 +10,7 @@ if #[cfg(feature = "ssr")] {
|
||||
use diesel::pg::Pg;
|
||||
use diesel::expression::AsExpression;
|
||||
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
|
||||
// Define pg_trgm operators
|
||||
// Functions do not use indices for queries, so we need to use operators
|
||||
|
@ -6,7 +6,7 @@ use cfg_if::cfg_if;
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use multer::Field;
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
use diesel::prelude::*;
|
||||
use log::*;
|
||||
use server_fn::error::NoCustomError;
|
||||
|
@ -1,7 +1,7 @@
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use diesel::prelude::*;
|
||||
use crate::database::get_db_conn;
|
||||
use crate::util::database::get_db_conn;
|
||||
|
||||
use pbkdf2::{
|
||||
password_hash::{
|
||||
|
@ -1,7 +1,3 @@
|
||||
use cfg_if::cfg_if;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "ssr")] {
|
||||
use leptos::logging::log;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
@ -110,6 +106,3 @@ pub fn migrate() {
|
||||
let db_con = &mut get_db_conn();
|
||||
db_con.run_pending_migrations(DB_MIGRATIONS).expect("Could not run database migrations");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ cfg_if! {
|
||||
pub mod audio;
|
||||
pub mod require_auth;
|
||||
pub mod fileserv;
|
||||
pub mod database;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user