From: Felix Ableitner Date: Fri, 18 Dec 2020 16:17:21 +0000 (+0100) Subject: Split lemmy_db into separate workspaces X-Git-Url: http://these/git/%7B%60%24%7BghostArchiveUrl%7D/static/%7BpictrsAvatarThumbnail%28?a=commitdiff_plain;h=089d812dc8ccb8bf87913f47d7dd080675799742;p=lemmy.git Split lemmy_db into separate workspaces --- diff --git a/Cargo.lock b/Cargo.lock index 23622c17..850a19e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1789,6 +1789,7 @@ dependencies = [ "chrono", "diesel", "lazy_static", + "lemmy_db_schema", "lemmy_utils", "log", "regex", @@ -1800,6 +1801,13 @@ dependencies = [ "url", ] +[[package]] +name = "lemmy_db_schema" +version = "0.1.0" +dependencies = [ + "diesel", +] + [[package]] name = "lemmy_rate_limit" version = "0.1.0" @@ -1835,6 +1843,7 @@ dependencies = [ "lemmy_api", "lemmy_apub", "lemmy_db", + "lemmy_db_schema", "lemmy_rate_limit", "lemmy_structs", "lemmy_utils", diff --git a/Cargo.toml b/Cargo.toml index f5b03adc..7f2b1a8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "lemmy_apub", "lemmy_utils", "lemmy_db", + "lemmy_db_schema", "lemmy_structs", "lemmy_rate_limit", "lemmy_websocket", @@ -21,6 +22,7 @@ members = [ lemmy_api = { path = "./lemmy_api" } lemmy_apub = { path = "./lemmy_apub" } lemmy_utils = { path = "./lemmy_utils" } +lemmy_db_schema = { path = "./lemmy_db_schema" } lemmy_db = { path = "./lemmy_db" } lemmy_structs = { path = "./lemmy_structs" } lemmy_rate_limit = { path = "./lemmy_rate_limit" } diff --git a/lemmy_db/Cargo.toml b/lemmy_db/Cargo.toml index d7c0fe3b..849dba8e 100644 --- a/lemmy_db/Cargo.toml +++ b/lemmy_db/Cargo.toml @@ -9,6 +9,7 @@ path = "src/lib.rs" [dependencies] lemmy_utils = { path = "../lemmy_utils" } +lemmy_db_schema = { path = "../lemmy_db_schema" } diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } chrono = { version = "0.4.19", features = ["serde"] } serde = { version = "1.0.118", features = ["derive"] } diff --git a/lemmy_db/src/aggregates/comment_aggregates.rs b/lemmy_db/src/aggregates/comment_aggregates.rs index 7ce52ed4..2bfd3939 100644 --- a/lemmy_db/src/aggregates/comment_aggregates.rs +++ b/lemmy_db/src/aggregates/comment_aggregates.rs @@ -1,5 +1,5 @@ -use crate::schema::comment_aggregates; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::comment_aggregates; use serde::Serialize; #[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)] diff --git a/lemmy_db/src/aggregates/community_aggregates.rs b/lemmy_db/src/aggregates/community_aggregates.rs index 8c977bf0..47c40f7b 100644 --- a/lemmy_db/src/aggregates/community_aggregates.rs +++ b/lemmy_db/src/aggregates/community_aggregates.rs @@ -1,5 +1,5 @@ -use crate::schema::community_aggregates; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::community_aggregates; use serde::Serialize; #[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)] diff --git a/lemmy_db/src/aggregates/post_aggregates.rs b/lemmy_db/src/aggregates/post_aggregates.rs index dff16f9b..6cb3a740 100644 --- a/lemmy_db/src/aggregates/post_aggregates.rs +++ b/lemmy_db/src/aggregates/post_aggregates.rs @@ -1,5 +1,5 @@ -use crate::schema::post_aggregates; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::post_aggregates; use serde::Serialize; #[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)] diff --git a/lemmy_db/src/aggregates/site_aggregates.rs b/lemmy_db/src/aggregates/site_aggregates.rs index 6856bfc9..a3bd199c 100644 --- a/lemmy_db/src/aggregates/site_aggregates.rs +++ b/lemmy_db/src/aggregates/site_aggregates.rs @@ -1,5 +1,5 @@ -use crate::schema::site_aggregates; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::site_aggregates; use serde::Serialize; #[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)] diff --git a/lemmy_db/src/aggregates/user_aggregates.rs b/lemmy_db/src/aggregates/user_aggregates.rs index 104bf6f7..f6eab467 100644 --- a/lemmy_db/src/aggregates/user_aggregates.rs +++ b/lemmy_db/src/aggregates/user_aggregates.rs @@ -1,5 +1,5 @@ -use crate::schema::user_aggregates; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::user_aggregates; use serde::Serialize; #[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Clone)] diff --git a/lemmy_db/src/lib.rs b/lemmy_db/src/lib.rs index 387e38a2..52180fb7 100644 --- a/lemmy_db/src/lib.rs +++ b/lemmy_db/src/lib.rs @@ -12,7 +12,6 @@ use serde::{Deserialize, Serialize}; use std::{env, env::VarError}; pub mod aggregates; -pub mod schema; pub mod source; pub mod views; diff --git a/lemmy_db/src/source/activity.rs b/lemmy_db/src/source/activity.rs index b4b54c6e..38a353a4 100644 --- a/lemmy_db/src/source/activity.rs +++ b/lemmy_db/src/source/activity.rs @@ -1,5 +1,6 @@ -use crate::{schema::activity, Crud}; +use crate::Crud; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::activity; use log::debug; use serde::Serialize; use serde_json::Value; @@ -32,12 +33,12 @@ pub struct ActivityForm { impl Crud for Activity { fn read(conn: &PgConnection, activity_id: i32) -> Result { - use crate::schema::activity::dsl::*; + use lemmy_db_schema::schema::activity::dsl::*; activity.find(activity_id).first::(conn) } fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result { - use crate::schema::activity::dsl::*; + use lemmy_db_schema::schema::activity::dsl::*; insert_into(activity) .values(new_activity) .get_result::(conn) @@ -48,13 +49,13 @@ impl Crud for Activity { activity_id: i32, new_activity: &ActivityForm, ) -> Result { - use crate::schema::activity::dsl::*; + use lemmy_db_schema::schema::activity::dsl::*; diesel::update(activity.find(activity_id)) .set(new_activity) .get_result::(conn) } fn delete(conn: &PgConnection, activity_id: i32) -> Result { - use crate::schema::activity::dsl::*; + use lemmy_db_schema::schema::activity::dsl::*; diesel::delete(activity.find(activity_id)).execute(conn) } } @@ -89,7 +90,7 @@ impl Activity { } pub fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result { - use crate::schema::activity::dsl::*; + use lemmy_db_schema::schema::activity::dsl::*; activity.filter(ap_id.eq(object_id)).first::(conn) } } diff --git a/lemmy_db/src/source/category.rs b/lemmy_db/src/source/category.rs index 95b65dc8..9ace8f51 100644 --- a/lemmy_db/src/source/category.rs +++ b/lemmy_db/src/source/category.rs @@ -1,8 +1,6 @@ -use crate::{ - schema::{category, category::dsl::*}, - Crud, -}; +use crate::Crud; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::{category, category::dsl::*}; use serde::Serialize; #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Clone)] diff --git a/lemmy_db/src/source/comment.rs b/lemmy_db/src/source/comment.rs index 380bdb3d..76cd9133 100644 --- a/lemmy_db/src/source/comment.rs +++ b/lemmy_db/src/source/comment.rs @@ -1,13 +1,7 @@ use super::post::Post; -use crate::{ - naive_now, - schema::{comment, comment_alias_1, comment_like, comment_saved}, - ApubObject, - Crud, - Likeable, - Saveable, -}; +use crate::{naive_now, ApubObject, Crud, Likeable, Saveable}; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::{comment, comment_alias_1, comment_like, comment_saved}; use serde::Serialize; use url::{ParseError, Url}; @@ -78,17 +72,17 @@ impl CommentForm { impl Crud for Comment { fn read(conn: &PgConnection, comment_id: i32) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; comment.find(comment_id).first::(conn) } fn delete(conn: &PgConnection, comment_id: i32) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::delete(comment.find(comment_id)).execute(conn) } fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; insert_into(comment) .values(comment_form) .get_result::(conn) @@ -99,7 +93,7 @@ impl Crud for Comment { comment_id: i32, comment_form: &CommentForm, ) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::update(comment.find(comment_id)) .set(comment_form) .get_result::(conn) @@ -108,12 +102,12 @@ impl Crud for Comment { impl ApubObject for Comment { fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; comment.filter(ap_id.eq(object_id)).first::(conn) } fn upsert(conn: &PgConnection, comment_form: &CommentForm) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; insert_into(comment) .values(comment_form) .on_conflict(ap_id) @@ -129,7 +123,7 @@ impl Comment { comment_id: i32, apub_id: String, ) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::update(comment.find(comment_id)) .set(ap_id.eq(apub_id)) @@ -140,7 +134,7 @@ impl Comment { conn: &PgConnection, for_creator_id: i32, ) -> Result, Error> { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::update(comment.filter(creator_id.eq(for_creator_id))) .set(( content.eq("*Permananently Deleted*"), @@ -155,7 +149,7 @@ impl Comment { comment_id: i32, new_deleted: bool, ) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::update(comment.find(comment_id)) .set((deleted.eq(new_deleted), updated.eq(naive_now()))) .get_result::(conn) @@ -166,7 +160,7 @@ impl Comment { comment_id: i32, new_removed: bool, ) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::update(comment.find(comment_id)) .set((removed.eq(new_removed), updated.eq(naive_now()))) .get_result::(conn) @@ -177,14 +171,14 @@ impl Comment { for_creator_id: i32, new_removed: bool, ) -> Result, Error> { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::update(comment.filter(creator_id.eq(for_creator_id))) .set((removed.eq(new_removed), updated.eq(naive_now()))) .get_results::(conn) } pub fn update_read(conn: &PgConnection, comment_id: i32, new_read: bool) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::update(comment.find(comment_id)) .set(read.eq(new_read)) .get_result::(conn) @@ -195,7 +189,7 @@ impl Comment { comment_id: i32, new_content: &str, ) -> Result { - use crate::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; diesel::update(comment.find(comment_id)) .set((content.eq(new_content), updated.eq(naive_now()))) .get_result::(conn) @@ -225,7 +219,7 @@ pub struct CommentLikeForm { impl Likeable for CommentLike { fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result { - use crate::schema::comment_like::dsl::*; + use lemmy_db_schema::schema::comment_like::dsl::*; insert_into(comment_like) .values(comment_like_form) .on_conflict((comment_id, user_id)) @@ -234,7 +228,7 @@ impl Likeable for CommentLike { .get_result::(conn) } fn remove(conn: &PgConnection, user_id: i32, comment_id: i32) -> Result { - use crate::schema::comment_like::dsl; + use lemmy_db_schema::schema::comment_like::dsl; diesel::delete( dsl::comment_like .filter(dsl::comment_id.eq(comment_id)) @@ -263,7 +257,7 @@ pub struct CommentSavedForm { impl Saveable for CommentSaved { fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result { - use crate::schema::comment_saved::dsl::*; + use lemmy_db_schema::schema::comment_saved::dsl::*; insert_into(comment_saved) .values(comment_saved_form) .on_conflict((comment_id, user_id)) @@ -272,7 +266,7 @@ impl Saveable for CommentSaved { .get_result::(conn) } fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result { - use crate::schema::comment_saved::dsl::*; + use lemmy_db_schema::schema::comment_saved::dsl::*; diesel::delete( comment_saved .filter(comment_id.eq(comment_saved_form.comment_id)) diff --git a/lemmy_db/src/source/comment_report.rs b/lemmy_db/src/source/comment_report.rs index a5375991..2937e631 100644 --- a/lemmy_db/src/source/comment_report.rs +++ b/lemmy_db/src/source/comment_report.rs @@ -1,8 +1,8 @@ +use crate::{naive_now, source::comment::Comment, Reportable}; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::comment_report; use serde::{Deserialize, Serialize}; -use crate::{naive_now, schema::comment_report, source::comment::Comment, Reportable}; - #[derive(Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone)] #[belongs_to(Comment)] #[table_name = "comment_report"] @@ -33,7 +33,7 @@ impl Reportable for CommentReport { /// * `conn` - the postgres connection /// * `comment_report_form` - the filled CommentReportForm to insert fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result { - use crate::schema::comment_report::dsl::*; + use lemmy_db_schema::schema::comment_report::dsl::*; insert_into(comment_report) .values(comment_report_form) .get_result::(conn) @@ -45,7 +45,7 @@ impl Reportable for CommentReport { /// * `report_id` - the id of the report to resolve /// * `by_resolver_id` - the id of the user resolving the report fn resolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result { - use crate::schema::comment_report::dsl::*; + use lemmy_db_schema::schema::comment_report::dsl::*; update(comment_report.find(report_id)) .set(( resolved.eq(true), @@ -61,7 +61,7 @@ impl Reportable for CommentReport { /// * `report_id` - the id of the report to unresolve /// * `by_resolver_id` - the id of the user unresolving the report fn unresolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result { - use crate::schema::comment_report::dsl::*; + use lemmy_db_schema::schema::comment_report::dsl::*; update(comment_report.find(report_id)) .set(( resolved.eq(false), diff --git a/lemmy_db/src/source/community.rs b/lemmy_db/src/source/community.rs index 0ad90da2..05bc3c5c 100644 --- a/lemmy_db/src/source/community.rs +++ b/lemmy_db/src/source/community.rs @@ -1,6 +1,5 @@ use crate::{ naive_now, - schema::{community, community_follower, community_moderator, community_user_ban}, views::{community::community_moderator_view::CommunityModeratorView, user_view::UserViewSafe}, ApubObject, Bannable, @@ -9,6 +8,12 @@ use crate::{ Joinable, }; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::{ + community, + community_follower, + community_moderator, + community_user_ban, +}; use serde::Serialize; #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)] @@ -56,7 +61,8 @@ pub struct CommunitySafe { } mod safe_type { - use crate::{schema::community::columns::*, source::community::Community, ToSafe}; + use crate::{source::community::Community, ToSafe}; + use lemmy_db_schema::schema::community::columns::*; type Columns = ( id, name, @@ -123,17 +129,17 @@ pub struct CommunityForm { impl Crud for Community { fn read(conn: &PgConnection, community_id: i32) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; community.find(community_id).first::(conn) } fn delete(conn: &PgConnection, community_id: i32) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; diesel::delete(community.find(community_id)).execute(conn) } fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; insert_into(community) .values(new_community) .get_result::(conn) @@ -144,7 +150,7 @@ impl Crud for Community { community_id: i32, new_community: &CommunityForm, ) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; diesel::update(community.find(community_id)) .set(new_community) .get_result::(conn) @@ -153,14 +159,14 @@ impl Crud for Community { impl ApubObject for Community { fn read_from_apub_id(conn: &PgConnection, for_actor_id: &str) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; community .filter(actor_id.eq(for_actor_id)) .first::(conn) } fn upsert(conn: &PgConnection, community_form: &CommunityForm) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; insert_into(community) .values(community_form) .on_conflict(actor_id) @@ -172,7 +178,7 @@ impl ApubObject for Community { impl Community { pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; community .filter(local.eq(true)) .filter(name.eq(community_name)) @@ -184,7 +190,7 @@ impl Community { community_id: i32, new_deleted: bool, ) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; diesel::update(community.find(community_id)) .set((deleted.eq(new_deleted), updated.eq(naive_now()))) .get_result::(conn) @@ -195,7 +201,7 @@ impl Community { community_id: i32, new_removed: bool, ) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; diesel::update(community.find(community_id)) .set((removed.eq(new_removed), updated.eq(naive_now()))) .get_result::(conn) @@ -206,7 +212,7 @@ impl Community { for_creator_id: i32, new_removed: bool, ) -> Result, Error> { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; diesel::update(community.filter(creator_id.eq(for_creator_id))) .set((removed.eq(new_removed), updated.eq(naive_now()))) .get_results::(conn) @@ -217,7 +223,7 @@ impl Community { community_id: i32, new_creator_id: i32, ) -> Result { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; diesel::update(community.find(community_id)) .set((creator_id.eq(new_creator_id), updated.eq(naive_now()))) .get_result::(conn) @@ -235,7 +241,7 @@ impl Community { } pub fn distinct_federated_communities(conn: &PgConnection) -> Result, Error> { - use crate::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; community.select(actor_id).distinct().load::(conn) } @@ -268,7 +274,7 @@ impl Joinable for CommunityModerator { conn: &PgConnection, community_user_form: &CommunityModeratorForm, ) -> Result { - use crate::schema::community_moderator::dsl::*; + use lemmy_db_schema::schema::community_moderator::dsl::*; insert_into(community_moderator) .values(community_user_form) .get_result::(conn) @@ -278,7 +284,7 @@ impl Joinable for CommunityModerator { conn: &PgConnection, community_user_form: &CommunityModeratorForm, ) -> Result { - use crate::schema::community_moderator::dsl::*; + use lemmy_db_schema::schema::community_moderator::dsl::*; diesel::delete( community_moderator .filter(community_id.eq(community_user_form.community_id)) @@ -290,7 +296,7 @@ impl Joinable for CommunityModerator { impl CommunityModerator { pub fn delete_for_community(conn: &PgConnection, for_community_id: i32) -> Result { - use crate::schema::community_moderator::dsl::*; + use lemmy_db_schema::schema::community_moderator::dsl::*; diesel::delete(community_moderator.filter(community_id.eq(for_community_id))).execute(conn) } @@ -298,7 +304,7 @@ impl CommunityModerator { conn: &PgConnection, for_user_id: i32, ) -> Result, Error> { - use crate::schema::community_moderator::dsl::*; + use lemmy_db_schema::schema::community_moderator::dsl::*; community_moderator .filter(user_id.eq(for_user_id)) .select(community_id) @@ -328,7 +334,7 @@ impl Bannable for CommunityUserBan { conn: &PgConnection, community_user_ban_form: &CommunityUserBanForm, ) -> Result { - use crate::schema::community_user_ban::dsl::*; + use lemmy_db_schema::schema::community_user_ban::dsl::*; insert_into(community_user_ban) .values(community_user_ban_form) .get_result::(conn) @@ -338,7 +344,7 @@ impl Bannable for CommunityUserBan { conn: &PgConnection, community_user_ban_form: &CommunityUserBanForm, ) -> Result { - use crate::schema::community_user_ban::dsl::*; + use lemmy_db_schema::schema::community_user_ban::dsl::*; diesel::delete( community_user_ban .filter(community_id.eq(community_user_ban_form.community_id)) @@ -372,7 +378,7 @@ impl Followable for CommunityFollower { conn: &PgConnection, community_follower_form: &CommunityFollowerForm, ) -> Result { - use crate::schema::community_follower::dsl::*; + use lemmy_db_schema::schema::community_follower::dsl::*; insert_into(community_follower) .values(community_follower_form) .on_conflict((community_id, user_id)) @@ -384,7 +390,7 @@ impl Followable for CommunityFollower { where Self: Sized, { - use crate::schema::community_follower::dsl::*; + use lemmy_db_schema::schema::community_follower::dsl::*; diesel::update( community_follower .filter(community_id.eq(community_id_)) @@ -397,7 +403,7 @@ impl Followable for CommunityFollower { conn: &PgConnection, community_follower_form: &CommunityFollowerForm, ) -> Result { - use crate::schema::community_follower::dsl::*; + use lemmy_db_schema::schema::community_follower::dsl::*; diesel::delete( community_follower .filter(community_id.eq(&community_follower_form.community_id)) @@ -408,7 +414,7 @@ impl Followable for CommunityFollower { // TODO: this function name only makes sense if you call it with a remote community. for a local // community, it will also return true if only remote followers exist fn has_local_followers(conn: &PgConnection, community_id_: i32) -> Result { - use crate::schema::community_follower::dsl::*; + use lemmy_db_schema::schema::community_follower::dsl::*; diesel::select(exists( community_follower.filter(community_id.eq(community_id_)), )) diff --git a/lemmy_db/src/source/moderator.rs b/lemmy_db/src/source/moderator.rs index 766c17fc..0766f49c 100644 --- a/lemmy_db/src/source/moderator.rs +++ b/lemmy_db/src/source/moderator.rs @@ -1,18 +1,16 @@ -use crate::{ - schema::{ - mod_add, - mod_add_community, - mod_ban, - mod_ban_from_community, - mod_lock_post, - mod_remove_comment, - mod_remove_community, - mod_remove_post, - mod_sticky_post, - }, - Crud, -}; +use crate::Crud; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::{ + mod_add, + mod_add_community, + mod_ban, + mod_ban_from_community, + mod_lock_post, + mod_remove_comment, + mod_remove_community, + mod_remove_post, + mod_sticky_post, +}; use serde::Serialize; #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)] @@ -37,19 +35,19 @@ pub struct ModRemovePostForm { impl Crud for ModRemovePost { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_remove_post::dsl::*; + use lemmy_db_schema::schema::mod_remove_post::dsl::*; mod_remove_post.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result { - use crate::schema::mod_remove_post::dsl::*; + use lemmy_db_schema::schema::mod_remove_post::dsl::*; insert_into(mod_remove_post) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result { - use crate::schema::mod_remove_post::dsl::*; + use lemmy_db_schema::schema::mod_remove_post::dsl::*; diesel::update(mod_remove_post.find(from_id)) .set(form) .get_result::(conn) @@ -76,19 +74,19 @@ pub struct ModLockPostForm { impl Crud for ModLockPost { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_lock_post::dsl::*; + use lemmy_db_schema::schema::mod_lock_post::dsl::*; mod_lock_post.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result { - use crate::schema::mod_lock_post::dsl::*; + use lemmy_db_schema::schema::mod_lock_post::dsl::*; insert_into(mod_lock_post) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result { - use crate::schema::mod_lock_post::dsl::*; + use lemmy_db_schema::schema::mod_lock_post::dsl::*; diesel::update(mod_lock_post.find(from_id)) .set(form) .get_result::(conn) @@ -115,19 +113,19 @@ pub struct ModStickyPostForm { impl Crud for ModStickyPost { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_sticky_post::dsl::*; + use lemmy_db_schema::schema::mod_sticky_post::dsl::*; mod_sticky_post.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModStickyPostForm) -> Result { - use crate::schema::mod_sticky_post::dsl::*; + use lemmy_db_schema::schema::mod_sticky_post::dsl::*; insert_into(mod_sticky_post) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModStickyPostForm) -> Result { - use crate::schema::mod_sticky_post::dsl::*; + use lemmy_db_schema::schema::mod_sticky_post::dsl::*; diesel::update(mod_sticky_post.find(from_id)) .set(form) .get_result::(conn) @@ -156,19 +154,19 @@ pub struct ModRemoveCommentForm { impl Crud for ModRemoveComment { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_remove_comment::dsl::*; + use lemmy_db_schema::schema::mod_remove_comment::dsl::*; mod_remove_comment.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result { - use crate::schema::mod_remove_comment::dsl::*; + use lemmy_db_schema::schema::mod_remove_comment::dsl::*; insert_into(mod_remove_comment) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result { - use crate::schema::mod_remove_comment::dsl::*; + use lemmy_db_schema::schema::mod_remove_comment::dsl::*; diesel::update(mod_remove_comment.find(from_id)) .set(form) .get_result::(conn) @@ -199,12 +197,12 @@ pub struct ModRemoveCommunityForm { impl Crud for ModRemoveCommunity { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_remove_community::dsl::*; + use lemmy_db_schema::schema::mod_remove_community::dsl::*; mod_remove_community.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result { - use crate::schema::mod_remove_community::dsl::*; + use lemmy_db_schema::schema::mod_remove_community::dsl::*; insert_into(mod_remove_community) .values(form) .get_result::(conn) @@ -215,7 +213,7 @@ impl Crud for ModRemoveCommunity { from_id: i32, form: &ModRemoveCommunityForm, ) -> Result { - use crate::schema::mod_remove_community::dsl::*; + use lemmy_db_schema::schema::mod_remove_community::dsl::*; diesel::update(mod_remove_community.find(from_id)) .set(form) .get_result::(conn) @@ -248,12 +246,12 @@ pub struct ModBanFromCommunityForm { impl Crud for ModBanFromCommunity { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_ban_from_community::dsl::*; + use lemmy_db_schema::schema::mod_ban_from_community::dsl::*; mod_ban_from_community.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result { - use crate::schema::mod_ban_from_community::dsl::*; + use lemmy_db_schema::schema::mod_ban_from_community::dsl::*; insert_into(mod_ban_from_community) .values(form) .get_result::(conn) @@ -264,7 +262,7 @@ impl Crud for ModBanFromCommunity { from_id: i32, form: &ModBanFromCommunityForm, ) -> Result { - use crate::schema::mod_ban_from_community::dsl::*; + use lemmy_db_schema::schema::mod_ban_from_community::dsl::*; diesel::update(mod_ban_from_community.find(from_id)) .set(form) .get_result::(conn) @@ -295,17 +293,17 @@ pub struct ModBanForm { impl Crud for ModBan { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_ban::dsl::*; + use lemmy_db_schema::schema::mod_ban::dsl::*; mod_ban.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModBanForm) -> Result { - use crate::schema::mod_ban::dsl::*; + use lemmy_db_schema::schema::mod_ban::dsl::*; insert_into(mod_ban).values(form).get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result { - use crate::schema::mod_ban::dsl::*; + use lemmy_db_schema::schema::mod_ban::dsl::*; diesel::update(mod_ban.find(from_id)) .set(form) .get_result::(conn) @@ -334,19 +332,19 @@ pub struct ModAddCommunityForm { impl Crud for ModAddCommunity { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_add_community::dsl::*; + use lemmy_db_schema::schema::mod_add_community::dsl::*; mod_add_community.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result { - use crate::schema::mod_add_community::dsl::*; + use lemmy_db_schema::schema::mod_add_community::dsl::*; insert_into(mod_add_community) .values(form) .get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result { - use crate::schema::mod_add_community::dsl::*; + use lemmy_db_schema::schema::mod_add_community::dsl::*; diesel::update(mod_add_community.find(from_id)) .set(form) .get_result::(conn) @@ -373,17 +371,17 @@ pub struct ModAddForm { impl Crud for ModAdd { fn read(conn: &PgConnection, from_id: i32) -> Result { - use crate::schema::mod_add::dsl::*; + use lemmy_db_schema::schema::mod_add::dsl::*; mod_add.find(from_id).first::(conn) } fn create(conn: &PgConnection, form: &ModAddForm) -> Result { - use crate::schema::mod_add::dsl::*; + use lemmy_db_schema::schema::mod_add::dsl::*; insert_into(mod_add).values(form).get_result::(conn) } fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result { - use crate::schema::mod_add::dsl::*; + use lemmy_db_schema::schema::mod_add::dsl::*; diesel::update(mod_add.find(from_id)) .set(form) .get_result::(conn) diff --git a/lemmy_db/src/source/password_reset_request.rs b/lemmy_db/src/source/password_reset_request.rs index 0cf0169f..3c9969e4 100644 --- a/lemmy_db/src/source/password_reset_request.rs +++ b/lemmy_db/src/source/password_reset_request.rs @@ -1,8 +1,6 @@ -use crate::{ - schema::{password_reset_request, password_reset_request::dsl::*}, - Crud, -}; +use crate::Crud; use diesel::{dsl::*, result::Error, PgConnection, *}; +use lemmy_db_schema::schema::{password_reset_request, password_reset_request::dsl::*}; use sha2::{Digest, Sha256}; #[derive(Queryable, Identifiable, PartialEq, Debug)] @@ -23,7 +21,6 @@ pub struct PasswordResetRequestForm { impl Crud for PasswordResetRequest { fn read(conn: &PgConnection, password_reset_request_id: i32) -> Result { - use crate::schema::password_reset_request::dsl::*; password_reset_request .find(password_reset_request_id) .first::(conn) diff --git a/lemmy_db/src/source/post.rs b/lemmy_db/src/source/post.rs index 098ce883..181157a2 100644 --- a/lemmy_db/src/source/post.rs +++ b/lemmy_db/src/source/post.rs @@ -1,13 +1,6 @@ -use crate::{ - naive_now, - schema::{post, post_like, post_read, post_saved}, - ApubObject, - Crud, - Likeable, - Readable, - Saveable, -}; +use crate::{naive_now, ApubObject, Crud, Likeable, Readable, Saveable}; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::{post, post_like, post_read, post_saved}; use serde::Serialize; use url::{ParseError, Url}; @@ -66,22 +59,22 @@ impl PostForm { impl Crud for Post { fn read(conn: &PgConnection, post_id: i32) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; post.find(post_id).first::(conn) } fn delete(conn: &PgConnection, post_id: i32) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; diesel::delete(post.find(post_id)).execute(conn) } fn create(conn: &PgConnection, new_post: &PostForm) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; insert_into(post).values(new_post).get_result::(conn) } fn update(conn: &PgConnection, post_id: i32, new_post: &PostForm) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; diesel::update(post.find(post_id)) .set(new_post) .get_result::(conn) @@ -90,12 +83,12 @@ impl Crud for Post { impl ApubObject for Post { fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; post.filter(ap_id.eq(object_id)).first::(conn) } fn upsert(conn: &PgConnection, post_form: &PostForm) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; insert_into(post) .values(post_form) .on_conflict(ap_id) @@ -107,7 +100,7 @@ impl ApubObject for Post { impl Post { pub fn read(conn: &PgConnection, post_id: i32) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; post.filter(id.eq(post_id)).first::(conn) } @@ -115,7 +108,7 @@ impl Post { conn: &PgConnection, the_community_id: i32, ) -> Result, Error> { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; post .filter(community_id.eq(the_community_id)) .then_order_by(published.desc()) @@ -125,7 +118,7 @@ impl Post { } pub fn update_ap_id(conn: &PgConnection, post_id: i32, apub_id: String) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; diesel::update(post.find(post_id)) .set(ap_id.eq(apub_id)) @@ -136,7 +129,7 @@ impl Post { conn: &PgConnection, for_creator_id: i32, ) -> Result, Error> { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; let perma_deleted = "*Permananently Deleted*"; let perma_deleted_url = "https://deleted.com"; @@ -157,7 +150,7 @@ impl Post { post_id: i32, new_deleted: bool, ) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; diesel::update(post.find(post_id)) .set((deleted.eq(new_deleted), updated.eq(naive_now()))) .get_result::(conn) @@ -168,7 +161,7 @@ impl Post { post_id: i32, new_removed: bool, ) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; diesel::update(post.find(post_id)) .set((removed.eq(new_removed), updated.eq(naive_now()))) .get_result::(conn) @@ -180,7 +173,7 @@ impl Post { for_community_id: Option, new_removed: bool, ) -> Result, Error> { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; let mut update = diesel::update(post).into_boxed(); update = update.filter(creator_id.eq(for_creator_id)); @@ -195,7 +188,7 @@ impl Post { } pub fn update_locked(conn: &PgConnection, post_id: i32, new_locked: bool) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; diesel::update(post.find(post_id)) .set(locked.eq(new_locked)) .get_result::(conn) @@ -206,7 +199,7 @@ impl Post { post_id: i32, new_stickied: bool, ) -> Result { - use crate::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; diesel::update(post.find(post_id)) .set(stickied.eq(new_stickied)) .get_result::(conn) @@ -238,7 +231,7 @@ pub struct PostLikeForm { impl Likeable for PostLike { fn like(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result { - use crate::schema::post_like::dsl::*; + use lemmy_db_schema::schema::post_like::dsl::*; insert_into(post_like) .values(post_like_form) .on_conflict((post_id, user_id)) @@ -247,7 +240,7 @@ impl Likeable for PostLike { .get_result::(conn) } fn remove(conn: &PgConnection, user_id: i32, post_id: i32) -> Result { - use crate::schema::post_like::dsl; + use lemmy_db_schema::schema::post_like::dsl; diesel::delete( dsl::post_like .filter(dsl::post_id.eq(post_id)) @@ -276,7 +269,7 @@ pub struct PostSavedForm { impl Saveable for PostSaved { fn save(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result { - use crate::schema::post_saved::dsl::*; + use lemmy_db_schema::schema::post_saved::dsl::*; insert_into(post_saved) .values(post_saved_form) .on_conflict((post_id, user_id)) @@ -285,7 +278,7 @@ impl Saveable for PostSaved { .get_result::(conn) } fn unsave(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result { - use crate::schema::post_saved::dsl::*; + use lemmy_db_schema::schema::post_saved::dsl::*; diesel::delete( post_saved .filter(post_id.eq(post_saved_form.post_id)) @@ -318,14 +311,14 @@ pub struct PostReadForm { impl Readable for PostRead { fn mark_as_read(conn: &PgConnection, post_read_form: &PostReadForm) -> Result { - use crate::schema::post_read::dsl::*; + use lemmy_db_schema::schema::post_read::dsl::*; insert_into(post_read) .values(post_read_form) .get_result::(conn) } fn mark_as_unread(conn: &PgConnection, post_read_form: &PostReadForm) -> Result { - use crate::schema::post_read::dsl::*; + use lemmy_db_schema::schema::post_read::dsl::*; diesel::delete( post_read .filter(post_id.eq(post_read_form.post_id)) diff --git a/lemmy_db/src/source/post_report.rs b/lemmy_db/src/source/post_report.rs index 6de82a25..af45aa3d 100644 --- a/lemmy_db/src/source/post_report.rs +++ b/lemmy_db/src/source/post_report.rs @@ -1,8 +1,8 @@ +use crate::{naive_now, source::post::Post, Reportable}; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::post_report; use serde::{Deserialize, Serialize}; -use crate::{naive_now, schema::post_report, source::post::Post, Reportable}; - #[derive(Identifiable, Queryable, Associations, PartialEq, Serialize, Deserialize, Debug, Clone)] #[belongs_to(Post)] #[table_name = "post_report"] @@ -37,7 +37,7 @@ impl Reportable for PostReport { /// * `conn` - the postgres connection /// * `post_report_form` - the filled CommentReportForm to insert fn report(conn: &PgConnection, post_report_form: &PostReportForm) -> Result { - use crate::schema::post_report::dsl::*; + use lemmy_db_schema::schema::post_report::dsl::*; insert_into(post_report) .values(post_report_form) .get_result::(conn) @@ -49,7 +49,7 @@ impl Reportable for PostReport { /// * `report_id` - the id of the report to resolve /// * `by_resolver_id` - the id of the user resolving the report fn resolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result { - use crate::schema::post_report::dsl::*; + use lemmy_db_schema::schema::post_report::dsl::*; update(post_report.find(report_id)) .set(( resolved.eq(true), @@ -65,7 +65,7 @@ impl Reportable for PostReport { /// * `report_id` - the id of the report to unresolve /// * `by_resolver_id` - the id of the user unresolving the report fn unresolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result { - use crate::schema::post_report::dsl::*; + use lemmy_db_schema::schema::post_report::dsl::*; update(post_report.find(report_id)) .set(( resolved.eq(false), diff --git a/lemmy_db/src/source/private_message.rs b/lemmy_db/src/source/private_message.rs index f474cf9a..e2b55c87 100644 --- a/lemmy_db/src/source/private_message.rs +++ b/lemmy_db/src/source/private_message.rs @@ -1,5 +1,6 @@ -use crate::{naive_now, schema::private_message, ApubObject, Crud}; +use crate::{naive_now, ApubObject, Crud}; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::private_message; use serde::Serialize; #[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)] @@ -33,12 +34,12 @@ pub struct PrivateMessageForm { impl Crud for PrivateMessage { fn read(conn: &PgConnection, private_message_id: i32) -> Result { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; private_message.find(private_message_id).first::(conn) } fn create(conn: &PgConnection, private_message_form: &PrivateMessageForm) -> Result { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; insert_into(private_message) .values(private_message_form) .get_result::(conn) @@ -49,7 +50,7 @@ impl Crud for PrivateMessage { private_message_id: i32, private_message_form: &PrivateMessageForm, ) -> Result { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; diesel::update(private_message.find(private_message_id)) .set(private_message_form) .get_result::(conn) @@ -61,14 +62,14 @@ impl ApubObject for PrivateMessage { where Self: Sized, { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; private_message .filter(ap_id.eq(object_id)) .first::(conn) } fn upsert(conn: &PgConnection, private_message_form: &PrivateMessageForm) -> Result { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; insert_into(private_message) .values(private_message_form) .on_conflict(ap_id) @@ -84,7 +85,7 @@ impl PrivateMessage { private_message_id: i32, apub_id: String, ) -> Result { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; diesel::update(private_message.find(private_message_id)) .set(ap_id.eq(apub_id)) @@ -96,7 +97,7 @@ impl PrivateMessage { private_message_id: i32, new_content: &str, ) -> Result { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; diesel::update(private_message.find(private_message_id)) .set((content.eq(new_content), updated.eq(naive_now()))) .get_result::(conn) @@ -107,7 +108,7 @@ impl PrivateMessage { private_message_id: i32, new_deleted: bool, ) -> Result { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; diesel::update(private_message.find(private_message_id)) .set(deleted.eq(new_deleted)) .get_result::(conn) @@ -118,14 +119,14 @@ impl PrivateMessage { private_message_id: i32, new_read: bool, ) -> Result { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; diesel::update(private_message.find(private_message_id)) .set(read.eq(new_read)) .get_result::(conn) } pub fn mark_all_as_read(conn: &PgConnection, for_recipient_id: i32) -> Result, Error> { - use crate::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; diesel::update( private_message .filter(recipient_id.eq(for_recipient_id)) diff --git a/lemmy_db/src/source/site.rs b/lemmy_db/src/source/site.rs index 2f3fbcdf..ad6f9ea6 100644 --- a/lemmy_db/src/source/site.rs +++ b/lemmy_db/src/source/site.rs @@ -1,5 +1,6 @@ -use crate::{naive_now, schema::site, Crud}; +use crate::{naive_now, Crud}; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::site; use serde::Serialize; #[derive(Queryable, Identifiable, PartialEq, Debug, Clone, Serialize)] @@ -35,17 +36,17 @@ pub struct SiteForm { impl Crud for Site { fn read(conn: &PgConnection, _site_id: i32) -> Result { - use crate::schema::site::dsl::*; + use lemmy_db_schema::schema::site::dsl::*; site.first::(conn) } fn create(conn: &PgConnection, new_site: &SiteForm) -> Result { - use crate::schema::site::dsl::*; + use lemmy_db_schema::schema::site::dsl::*; insert_into(site).values(new_site).get_result::(conn) } fn update(conn: &PgConnection, site_id: i32, new_site: &SiteForm) -> Result { - use crate::schema::site::dsl::*; + use lemmy_db_schema::schema::site::dsl::*; diesel::update(site.find(site_id)) .set(new_site) .get_result::(conn) @@ -54,7 +55,7 @@ impl Crud for Site { impl Site { pub fn transfer(conn: &PgConnection, new_creator_id: i32) -> Result { - use crate::schema::site::dsl::*; + use lemmy_db_schema::schema::site::dsl::*; diesel::update(site.find(1)) .set((creator_id.eq(new_creator_id), updated.eq(naive_now()))) .get_result::(conn) diff --git a/lemmy_db/src/source/user.rs b/lemmy_db/src/source/user.rs index 601e6e8c..809a579a 100644 --- a/lemmy_db/src/source/user.rs +++ b/lemmy_db/src/source/user.rs @@ -1,12 +1,7 @@ -use crate::{ - is_email_regex, - naive_now, - schema::{user_, user_::dsl::*, user_alias_1, user_alias_2}, - ApubObject, - Crud, -}; +use crate::{is_email_regex, naive_now, ApubObject, Crud}; use bcrypt::{hash, DEFAULT_COST}; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::{user_, user_::dsl::*, user_alias_1, user_alias_2}; use lemmy_utils::settings::Settings; use serde::Serialize; @@ -62,7 +57,8 @@ pub struct UserSafe { } mod safe_type { - use crate::{schema::user_::columns::*, source::user::User_, ToSafe}; + use crate::{source::user::User_, ToSafe}; + use lemmy_db_schema::schema::user_::columns::*; type Columns = ( id, name, @@ -154,7 +150,8 @@ pub struct UserSafeAlias1 { } mod safe_type_alias_1 { - use crate::{schema::user_alias_1::columns::*, source::user::UserAlias1, ToSafe}; + use crate::{source::user::UserAlias1, ToSafe}; + use lemmy_db_schema::schema::user_alias_1::columns::*; type Columns = ( id, name, @@ -246,7 +243,8 @@ pub struct UserSafeAlias2 { } mod safe_type_alias_2 { - use crate::{schema::user_alias_2::columns::*, source::user::UserAlias2, ToSafe}; + use crate::{source::user::UserAlias2, ToSafe}; + use lemmy_db_schema::schema::user_alias_2::columns::*; type Columns = ( id, name, @@ -338,7 +336,7 @@ impl Crud for User_ { impl ApubObject for User_ { fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result { - use crate::schema::user_::dsl::*; + use lemmy_db_schema::schema::user_::dsl::*; user_ .filter(deleted.eq(false)) .filter(actor_id.eq(object_id)) diff --git a/lemmy_db/src/source/user_mention.rs b/lemmy_db/src/source/user_mention.rs index bf53cb42..a61d08d2 100644 --- a/lemmy_db/src/source/user_mention.rs +++ b/lemmy_db/src/source/user_mention.rs @@ -1,6 +1,7 @@ use super::comment::Comment; -use crate::{schema::user_mention, Crud}; +use crate::Crud; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::user_mention; use serde::Serialize; #[derive(Clone, Queryable, Associations, Identifiable, PartialEq, Debug, Serialize)] @@ -24,12 +25,12 @@ pub struct UserMentionForm { impl Crud for UserMention { fn read(conn: &PgConnection, user_mention_id: i32) -> Result { - use crate::schema::user_mention::dsl::*; + use lemmy_db_schema::schema::user_mention::dsl::*; user_mention.find(user_mention_id).first::(conn) } fn create(conn: &PgConnection, user_mention_form: &UserMentionForm) -> Result { - use crate::schema::user_mention::dsl::*; + use lemmy_db_schema::schema::user_mention::dsl::*; // since the return here isnt utilized, we dont need to do an update // but get_result doesnt return the existing row here insert_into(user_mention) @@ -45,7 +46,7 @@ impl Crud for UserMention { user_mention_id: i32, user_mention_form: &UserMentionForm, ) -> Result { - use crate::schema::user_mention::dsl::*; + use lemmy_db_schema::schema::user_mention::dsl::*; diesel::update(user_mention.find(user_mention_id)) .set(user_mention_form) .get_result::(conn) @@ -58,14 +59,14 @@ impl UserMention { user_mention_id: i32, new_read: bool, ) -> Result { - use crate::schema::user_mention::dsl::*; + use lemmy_db_schema::schema::user_mention::dsl::*; diesel::update(user_mention.find(user_mention_id)) .set(read.eq(new_read)) .get_result::(conn) } pub fn mark_all_as_read(conn: &PgConnection, for_recipient_id: i32) -> Result, Error> { - use crate::schema::user_mention::dsl::*; + use lemmy_db_schema::schema::user_mention::dsl::*; diesel::update( user_mention .filter(recipient_id.eq(for_recipient_id)) diff --git a/lemmy_db/src/views/comment_report_view.rs b/lemmy_db/src/views/comment_report_view.rs index 540bb756..0f55b432 100644 --- a/lemmy_db/src/views/comment_report_view.rs +++ b/lemmy_db/src/views/comment_report_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2}, source::{ comment::Comment, comment_report::CommentReport, @@ -13,6 +12,15 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{ + comment, + comment_report, + community, + post, + user_, + user_alias_1, + user_alias_2, +}; use serde::Serialize; #[derive(Debug, PartialEq, Serialize, Clone)] diff --git a/lemmy_db/src/views/comment_view.rs b/lemmy_db/src/views/comment_view.rs index d85f654f..7f78c20f 100644 --- a/lemmy_db/src/views/comment_view.rs +++ b/lemmy_db/src/views/comment_view.rs @@ -3,19 +3,6 @@ use crate::{ functions::hot_rank, fuzzy_search, limit_and_offset, - schema::{ - comment, - comment_aggregates, - comment_alias_1, - comment_like, - comment_saved, - community, - community_follower, - community_user_ban, - post, - user_, - user_alias_1, - }, source::{ comment::{Comment, CommentAlias1, CommentSaved}, community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan}, @@ -29,6 +16,19 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{ + comment, + comment_aggregates, + comment_alias_1, + comment_like, + comment_saved, + community, + community_follower, + community_user_ban, + post, + user_, + user_alias_1, +}; use serde::Serialize; #[derive(Debug, PartialEq, Serialize, Clone)] diff --git a/lemmy_db/src/views/community/community_follower_view.rs b/lemmy_db/src/views/community/community_follower_view.rs index 7de9cc3a..243b9142 100644 --- a/lemmy_db/src/views/community/community_follower_view.rs +++ b/lemmy_db/src/views/community/community_follower_view.rs @@ -1,5 +1,4 @@ use crate::{ - schema::{community, community_follower, user_}, source::{ community::{Community, CommunitySafe}, user::{UserSafe, User_}, @@ -8,6 +7,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, community_follower, user_}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/community/community_moderator_view.rs b/lemmy_db/src/views/community/community_moderator_view.rs index 751e4623..8762b975 100644 --- a/lemmy_db/src/views/community/community_moderator_view.rs +++ b/lemmy_db/src/views/community/community_moderator_view.rs @@ -1,5 +1,4 @@ use crate::{ - schema::{community, community_moderator, user_}, source::{ community::{Community, CommunitySafe}, user::{UserSafe, User_}, @@ -8,6 +7,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, community_moderator, user_}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/community/community_user_ban_view.rs b/lemmy_db/src/views/community/community_user_ban_view.rs index 3358f01b..5dba4ebd 100644 --- a/lemmy_db/src/views/community/community_user_ban_view.rs +++ b/lemmy_db/src/views/community/community_user_ban_view.rs @@ -1,5 +1,4 @@ use crate::{ - schema::{community, community_user_ban, user_}, source::{ community::{Community, CommunitySafe}, user::{UserSafe, User_}, @@ -7,6 +6,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, community_user_ban, user_}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/community/community_view.rs b/lemmy_db/src/views/community/community_view.rs index fcc707c0..6c951b33 100644 --- a/lemmy_db/src/views/community/community_view.rs +++ b/lemmy_db/src/views/community/community_view.rs @@ -3,7 +3,6 @@ use crate::{ functions::hot_rank, fuzzy_search, limit_and_offset, - schema::{category, community, community_aggregates, community_follower, user_}, source::{ category::Category, community::{Community, CommunityFollower, CommunitySafe}, @@ -15,6 +14,13 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{ + category, + community, + community_aggregates, + community_follower, + user_, +}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_add_community_view.rs b/lemmy_db/src/views/moderator/mod_add_community_view.rs index 402c5fe1..1dd7cfc4 100644 --- a/lemmy_db/src/views/moderator/mod_add_community_view.rs +++ b/lemmy_db/src/views/moderator/mod_add_community_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{community, mod_add_community, user_, user_alias_1}, source::{ community::{Community, CommunitySafe}, moderator::ModAddCommunity, @@ -10,6 +9,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, mod_add_community, user_, user_alias_1}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_add_view.rs b/lemmy_db/src/views/moderator/mod_add_view.rs index fc1993d4..06648ad7 100644 --- a/lemmy_db/src/views/moderator/mod_add_view.rs +++ b/lemmy_db/src/views/moderator/mod_add_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{mod_add, user_, user_alias_1}, source::{ moderator::ModAdd, user::{UserAlias1, UserSafe, UserSafeAlias1, User_}, @@ -9,6 +8,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{mod_add, user_, user_alias_1}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_ban_from_community_view.rs b/lemmy_db/src/views/moderator/mod_ban_from_community_view.rs index 6ad232e8..3992518b 100644 --- a/lemmy_db/src/views/moderator/mod_ban_from_community_view.rs +++ b/lemmy_db/src/views/moderator/mod_ban_from_community_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{community, mod_ban_from_community, user_, user_alias_1}, source::{ community::{Community, CommunitySafe}, moderator::ModBanFromCommunity, @@ -10,6 +9,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, mod_ban_from_community, user_, user_alias_1}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_ban_view.rs b/lemmy_db/src/views/moderator/mod_ban_view.rs index 28214d2d..52e89025 100644 --- a/lemmy_db/src/views/moderator/mod_ban_view.rs +++ b/lemmy_db/src/views/moderator/mod_ban_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{mod_ban, user_, user_alias_1}, source::{ moderator::ModBan, user::{UserAlias1, UserSafe, UserSafeAlias1, User_}, @@ -9,6 +8,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{mod_ban, user_, user_alias_1}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_lock_post_view.rs b/lemmy_db/src/views/moderator/mod_lock_post_view.rs index 8182b54f..2d71a881 100644 --- a/lemmy_db/src/views/moderator/mod_lock_post_view.rs +++ b/lemmy_db/src/views/moderator/mod_lock_post_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{community, mod_lock_post, post, user_}, source::{ community::{Community, CommunitySafe}, moderator::ModLockPost, @@ -11,6 +10,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, mod_lock_post, post, user_}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_remove_comment_view.rs b/lemmy_db/src/views/moderator/mod_remove_comment_view.rs index fb4b7772..4fa82eed 100644 --- a/lemmy_db/src/views/moderator/mod_remove_comment_view.rs +++ b/lemmy_db/src/views/moderator/mod_remove_comment_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{comment, community, mod_remove_comment, post, user_, user_alias_1}, source::{ comment::Comment, community::{Community, CommunitySafe}, @@ -12,6 +11,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{comment, community, mod_remove_comment, post, user_, user_alias_1}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_remove_community_view.rs b/lemmy_db/src/views/moderator/mod_remove_community_view.rs index daaf6d78..1700ac2d 100644 --- a/lemmy_db/src/views/moderator/mod_remove_community_view.rs +++ b/lemmy_db/src/views/moderator/mod_remove_community_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{community, mod_remove_community, user_}, source::{ community::{Community, CommunitySafe}, moderator::ModRemoveCommunity, @@ -10,6 +9,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, mod_remove_community, user_}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_remove_post_view.rs b/lemmy_db/src/views/moderator/mod_remove_post_view.rs index 613a8a54..d21e985c 100644 --- a/lemmy_db/src/views/moderator/mod_remove_post_view.rs +++ b/lemmy_db/src/views/moderator/mod_remove_post_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{community, mod_remove_post, post, user_}, source::{ community::{Community, CommunitySafe}, moderator::ModRemovePost, @@ -11,6 +10,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, mod_remove_post, post, user_}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/moderator/mod_sticky_post_view.rs b/lemmy_db/src/views/moderator/mod_sticky_post_view.rs index 9a3d118b..ec277159 100644 --- a/lemmy_db/src/views/moderator/mod_sticky_post_view.rs +++ b/lemmy_db/src/views/moderator/mod_sticky_post_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{community, mod_sticky_post, post, user_}, source::{ community::{Community, CommunitySafe}, moderator::ModStickyPost, @@ -11,6 +10,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, mod_sticky_post, post, user_}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/post_report_view.rs b/lemmy_db/src/views/post_report_view.rs index d39adfd5..75bfac95 100644 --- a/lemmy_db/src/views/post_report_view.rs +++ b/lemmy_db/src/views/post_report_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{community, post, post_report, user_, user_alias_1, user_alias_2}, source::{ community::{Community, CommunitySafe}, post::Post, @@ -12,6 +11,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{community, post, post_report, user_, user_alias_1, user_alias_2}; use serde::Serialize; #[derive(Debug, PartialEq, Serialize, Clone)] diff --git a/lemmy_db/src/views/post_view.rs b/lemmy_db/src/views/post_view.rs index f95cf118..25d86aa1 100644 --- a/lemmy_db/src/views/post_view.rs +++ b/lemmy_db/src/views/post_view.rs @@ -3,17 +3,6 @@ use crate::{ functions::hot_rank, fuzzy_search, limit_and_offset, - schema::{ - community, - community_follower, - community_user_ban, - post, - post_aggregates, - post_like, - post_read, - post_saved, - user_, - }, source::{ community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan}, post::{Post, PostRead, PostSaved}, @@ -26,6 +15,17 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{ + community, + community_follower, + community_user_ban, + post, + post_aggregates, + post_like, + post_read, + post_saved, + user_, +}; use serde::Serialize; #[derive(Debug, PartialEq, Serialize, Clone)] diff --git a/lemmy_db/src/views/private_message_view.rs b/lemmy_db/src/views/private_message_view.rs index 43d960a8..5d594b12 100644 --- a/lemmy_db/src/views/private_message_view.rs +++ b/lemmy_db/src/views/private_message_view.rs @@ -1,6 +1,5 @@ use crate::{ limit_and_offset, - schema::{private_message, user_, user_alias_1}, source::{ private_message::PrivateMessage, user::{UserAlias1, UserSafe, UserSafeAlias1, User_}, @@ -10,6 +9,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{private_message, user_, user_alias_1}; use serde::Serialize; #[derive(Debug, PartialEq, Serialize, Clone)] diff --git a/lemmy_db/src/views/site_view.rs b/lemmy_db/src/views/site_view.rs index d10702fc..d956e2e1 100644 --- a/lemmy_db/src/views/site_view.rs +++ b/lemmy_db/src/views/site_view.rs @@ -1,5 +1,4 @@ use crate::{ - schema::{site, user_}, source::{ site::Site, user::{UserSafe, User_}, @@ -7,6 +6,7 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{site, user_}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db/src/views/user_mention_view.rs b/lemmy_db/src/views/user_mention_view.rs index 67616fbc..bb5fa009 100644 --- a/lemmy_db/src/views/user_mention_view.rs +++ b/lemmy_db/src/views/user_mention_view.rs @@ -2,19 +2,6 @@ use crate::{ aggregates::comment_aggregates::CommentAggregates, functions::hot_rank, limit_and_offset, - schema::{ - comment, - comment_aggregates, - comment_like, - comment_saved, - community, - community_follower, - community_user_ban, - post, - user_, - user_alias_1, - user_mention, - }, source::{ comment::{Comment, CommentSaved}, community::{Community, CommunityFollower, CommunitySafe, CommunityUserBan}, @@ -28,6 +15,19 @@ use crate::{ ToSafe, }; use diesel::{result::Error, *}; +use lemmy_db_schema::schema::{ + comment, + comment_aggregates, + comment_like, + comment_saved, + community, + community_follower, + community_user_ban, + post, + user_, + user_alias_1, + user_mention, +}; use serde::Serialize; #[derive(Debug, PartialEq, Serialize, Clone)] diff --git a/lemmy_db/src/views/user_view.rs b/lemmy_db/src/views/user_view.rs index 587ebf61..8f59691a 100644 --- a/lemmy_db/src/views/user_view.rs +++ b/lemmy_db/src/views/user_view.rs @@ -2,7 +2,6 @@ use crate::{ aggregates::user_aggregates::UserAggregates, fuzzy_search, limit_and_offset, - schema::{user_, user_aggregates}, source::user::{UserSafe, User_}, views::ViewToVec, MaybeOptional, @@ -10,6 +9,7 @@ use crate::{ ToSafe, }; use diesel::{dsl::*, result::Error, *}; +use lemmy_db_schema::schema::{user_, user_aggregates}; use serde::Serialize; #[derive(Debug, Serialize, Clone)] diff --git a/lemmy_db_schema/Cargo.toml b/lemmy_db_schema/Cargo.toml new file mode 100644 index 00000000..3ef97550 --- /dev/null +++ b/lemmy_db_schema/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "lemmy_db_schema" +version = "0.1.0" +edition = "2018" + +[dependencies] +diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diff --git a/lemmy_db_schema/src/lib.rs b/lemmy_db_schema/src/lib.rs new file mode 100644 index 00000000..b37d9461 --- /dev/null +++ b/lemmy_db_schema/src/lib.rs @@ -0,0 +1,4 @@ +#[macro_use] +extern crate diesel; + +pub mod schema; diff --git a/lemmy_db/src/schema.rs b/lemmy_db_schema/src/schema.rs similarity index 100% rename from lemmy_db/src/schema.rs rename to lemmy_db_schema/src/schema.rs diff --git a/src/code_migrations.rs b/src/code_migrations.rs index 7a749e9b..6a39d0da 100644 --- a/src/code_migrations.rs +++ b/src/code_migrations.rs @@ -33,7 +33,7 @@ pub fn run_advanced_migrations(conn: &PgConnection) -> Result<(), LemmyError> { } fn user_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> { - use lemmy_db::schema::user_::dsl::*; + use lemmy_db_schema::schema::user_::dsl::*; info!("Running user_updates_2020_04_02"); @@ -86,7 +86,7 @@ fn user_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> { } fn community_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> { - use lemmy_db::schema::community::dsl::*; + use lemmy_db_schema::schema::community::dsl::*; info!("Running community_updates_2020_04_02"); @@ -132,7 +132,7 @@ fn community_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> { } fn post_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> { - use lemmy_db::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; info!("Running post_updates_2020_04_03"); @@ -157,7 +157,7 @@ fn post_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> { } fn comment_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> { - use lemmy_db::schema::comment::dsl::*; + use lemmy_db_schema::schema::comment::dsl::*; info!("Running comment_updates_2020_04_03"); @@ -182,7 +182,7 @@ fn comment_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> { } fn private_message_updates_2020_05_05(conn: &PgConnection) -> Result<(), LemmyError> { - use lemmy_db::schema::private_message::dsl::*; + use lemmy_db_schema::schema::private_message::dsl::*; info!("Running private_message_updates_2020_05_05"); @@ -203,7 +203,7 @@ fn private_message_updates_2020_05_05(conn: &PgConnection) -> Result<(), LemmyEr } fn post_thumbnail_url_updates_2020_07_27(conn: &PgConnection) -> Result<(), LemmyError> { - use lemmy_db::schema::post::dsl::*; + use lemmy_db_schema::schema::post::dsl::*; info!("Running post_thumbnail_url_updates_2020_07_27");