]> Untitled Git - lemmy.git/commitdiff
Split lemmy_db into separate workspaces
authorFelix Ableitner <me@nutomic.com>
Fri, 18 Dec 2020 16:17:21 +0000 (17:17 +0100)
committerFelix Ableitner <me@nutomic.com>
Fri, 18 Dec 2020 16:17:44 +0000 (17:17 +0100)
47 files changed:
Cargo.lock
Cargo.toml
lemmy_db/Cargo.toml
lemmy_db/src/aggregates/comment_aggregates.rs
lemmy_db/src/aggregates/community_aggregates.rs
lemmy_db/src/aggregates/post_aggregates.rs
lemmy_db/src/aggregates/site_aggregates.rs
lemmy_db/src/aggregates/user_aggregates.rs
lemmy_db/src/lib.rs
lemmy_db/src/source/activity.rs
lemmy_db/src/source/category.rs
lemmy_db/src/source/comment.rs
lemmy_db/src/source/comment_report.rs
lemmy_db/src/source/community.rs
lemmy_db/src/source/moderator.rs
lemmy_db/src/source/password_reset_request.rs
lemmy_db/src/source/post.rs
lemmy_db/src/source/post_report.rs
lemmy_db/src/source/private_message.rs
lemmy_db/src/source/site.rs
lemmy_db/src/source/user.rs
lemmy_db/src/source/user_mention.rs
lemmy_db/src/views/comment_report_view.rs
lemmy_db/src/views/comment_view.rs
lemmy_db/src/views/community/community_follower_view.rs
lemmy_db/src/views/community/community_moderator_view.rs
lemmy_db/src/views/community/community_user_ban_view.rs
lemmy_db/src/views/community/community_view.rs
lemmy_db/src/views/moderator/mod_add_community_view.rs
lemmy_db/src/views/moderator/mod_add_view.rs
lemmy_db/src/views/moderator/mod_ban_from_community_view.rs
lemmy_db/src/views/moderator/mod_ban_view.rs
lemmy_db/src/views/moderator/mod_lock_post_view.rs
lemmy_db/src/views/moderator/mod_remove_comment_view.rs
lemmy_db/src/views/moderator/mod_remove_community_view.rs
lemmy_db/src/views/moderator/mod_remove_post_view.rs
lemmy_db/src/views/moderator/mod_sticky_post_view.rs
lemmy_db/src/views/post_report_view.rs
lemmy_db/src/views/post_view.rs
lemmy_db/src/views/private_message_view.rs
lemmy_db/src/views/site_view.rs
lemmy_db/src/views/user_mention_view.rs
lemmy_db/src/views/user_view.rs
lemmy_db_schema/Cargo.toml [new file with mode: 0644]
lemmy_db_schema/src/lib.rs [new file with mode: 0644]
lemmy_db_schema/src/schema.rs [moved from lemmy_db/src/schema.rs with 100% similarity]
src/code_migrations.rs

index 23622c17a7f783a7e09a467a3ab6ec336990d8c7..850a19e5eb31910efeca12501ba74fa72ba92c7c 100644 (file)
@@ -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",
index f5b03adc58bc5fcbd9b3262295a35991db0fcfb5..7f2b1a8be017defdba0706a8229802ed31c5ccc1 100644 (file)
@@ -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" }
index d7c0fe3b0ee7c018df756bfaaf0515b69186b701..849dba8e72b1da8bc4f443bc51988fd942f7460f 100644 (file)
@@ -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"] }
index 7ce52ed42c01e1c529fd0b184ba1ae9a6a58181a..2bfd39393354530d7663edffa5913fe062e4e846 100644 (file)
@@ -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)]
index 8c977bf0ca26056e46ecb79a9cf0e1c1e5a14dae..47c40f7bc79be2cae8e780010ae244616044f5ff 100644 (file)
@@ -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)]
index dff16f9b102bcc7d0644a511d7bead2dd6626e92..6cb3a7406721ae941f7abf10c8626c42cab61eb4 100644 (file)
@@ -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)]
index 6856bfc9e5a411cf8c69bdd3ac83983f9344b16f..a3bd199c15b52e24552cb25952dda3bac5acc640 100644 (file)
@@ -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)]
index 104bf6f7dfc9350647a33d03dafe360c0c7e2fc4..f6eab46792e6299fbd3c429de74738c72d8cf591 100644 (file)
@@ -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)]
index 387e38a2829471e219e5bee198cbc38703be0f90..52180fb72f069d69b56dd81053576f367a4afc2a 100644 (file)
@@ -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;
 
index b4b54c6ed293ad2681af14e75b16bfad4102eeaa..38a353a4a367296e025a4134c4d39fb0637b7df7 100644 (file)
@@ -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<ActivityForm> for Activity {
   fn read(conn: &PgConnection, activity_id: i32) -> Result<Self, Error> {
-    use crate::schema::activity::dsl::*;
+    use lemmy_db_schema::schema::activity::dsl::*;
     activity.find(activity_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
-    use crate::schema::activity::dsl::*;
+    use lemmy_db_schema::schema::activity::dsl::*;
     insert_into(activity)
       .values(new_activity)
       .get_result::<Self>(conn)
@@ -48,13 +49,13 @@ impl Crud<ActivityForm> for Activity {
     activity_id: i32,
     new_activity: &ActivityForm,
   ) -> Result<Self, Error> {
-    use crate::schema::activity::dsl::*;
+    use lemmy_db_schema::schema::activity::dsl::*;
     diesel::update(activity.find(activity_id))
       .set(new_activity)
       .get_result::<Self>(conn)
   }
   fn delete(conn: &PgConnection, activity_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use crate::schema::activity::dsl::*;
+    use lemmy_db_schema::schema::activity::dsl::*;
     activity.filter(ap_id.eq(object_id)).first::<Self>(conn)
   }
 }
index 95b65dc823ea31dc51f0bd8e6aafdb3193948565..9ace8f512bf815ffeb9b71f5575c87af2405d4b0 100644 (file)
@@ -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)]
index 380bdb3d157db6b1a259cc81dcf8416549c3cfa3..76cd9133d09828d37008aa54d8f144f34f194e98 100644 (file)
@@ -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<CommentForm> for Comment {
   fn read(conn: &PgConnection, comment_id: i32) -> Result<Self, Error> {
-    use crate::schema::comment::dsl::*;
+    use lemmy_db_schema::schema::comment::dsl::*;
     comment.find(comment_id).first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, comment_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use crate::schema::comment::dsl::*;
+    use lemmy_db_schema::schema::comment::dsl::*;
     insert_into(comment)
       .values(comment_form)
       .get_result::<Self>(conn)
@@ -99,7 +93,7 @@ impl Crud<CommentForm> for Comment {
     comment_id: i32,
     comment_form: &CommentForm,
   ) -> Result<Self, Error> {
-    use crate::schema::comment::dsl::*;
+    use lemmy_db_schema::schema::comment::dsl::*;
     diesel::update(comment.find(comment_id))
       .set(comment_form)
       .get_result::<Self>(conn)
@@ -108,12 +102,12 @@ impl Crud<CommentForm> for Comment {
 
 impl ApubObject<CommentForm> for Comment {
   fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result<Self, Error> {
-    use crate::schema::comment::dsl::*;
+    use lemmy_db_schema::schema::comment::dsl::*;
     comment.filter(ap_id.eq(object_id)).first::<Self>(conn)
   }
 
   fn upsert(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
-    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<Self, Error> {
-    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<Vec<Self>, 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<Self, Error> {
-    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::<Self>(conn)
@@ -166,7 +160,7 @@ impl Comment {
     comment_id: i32,
     new_removed: bool,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -177,14 +171,14 @@ impl Comment {
     for_creator_id: i32,
     new_removed: bool,
   ) -> Result<Vec<Self>, 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::<Self>(conn)
   }
 
   pub fn update_read(conn: &PgConnection, comment_id: i32, new_read: bool) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -195,7 +189,7 @@ impl Comment {
     comment_id: i32,
     new_content: &str,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -225,7 +219,7 @@ pub struct CommentLikeForm {
 
 impl Likeable<CommentLikeForm> for CommentLike {
   fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
-    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<CommentLikeForm> for CommentLike {
       .get_result::<Self>(conn)
   }
   fn remove(conn: &PgConnection, user_id: i32, comment_id: i32) -> Result<usize, Error> {
-    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<CommentSavedForm> for CommentSaved {
   fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
-    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<CommentSavedForm> for CommentSaved {
       .get_result::<Self>(conn)
   }
   fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<usize, Error> {
-    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))
index a53759916f1acbfe86867cd56a69cca8247e5924..2937e6315cc34859419611fefbfcb57cf643b6de 100644 (file)
@@ -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<CommentReportForm> for CommentReport {
   /// * `conn` - the postgres connection
   /// * `comment_report_form` - the filled CommentReportForm to insert
   fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
-    use crate::schema::comment_report::dsl::*;
+    use lemmy_db_schema::schema::comment_report::dsl::*;
     insert_into(comment_report)
       .values(comment_report_form)
       .get_result::<Self>(conn)
@@ -45,7 +45,7 @@ impl Reportable<CommentReportForm> 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<usize, Error> {
-    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<CommentReportForm> 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<usize, Error> {
-    use crate::schema::comment_report::dsl::*;
+    use lemmy_db_schema::schema::comment_report::dsl::*;
     update(comment_report.find(report_id))
       .set((
         resolved.eq(false),
index 0ad90da287c9f99fd1c6c691f80f5cdd562196cd..05bc3c5c7193be9e64d2a13a68538f4fa8f1ddb7 100644 (file)
@@ -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<CommunityForm> for Community {
   fn read(conn: &PgConnection, community_id: i32) -> Result<Self, Error> {
-    use crate::schema::community::dsl::*;
+    use lemmy_db_schema::schema::community::dsl::*;
     community.find(community_id).first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, community_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use crate::schema::community::dsl::*;
+    use lemmy_db_schema::schema::community::dsl::*;
     insert_into(community)
       .values(new_community)
       .get_result::<Self>(conn)
@@ -144,7 +150,7 @@ impl Crud<CommunityForm> for Community {
     community_id: i32,
     new_community: &CommunityForm,
   ) -> Result<Self, Error> {
-    use crate::schema::community::dsl::*;
+    use lemmy_db_schema::schema::community::dsl::*;
     diesel::update(community.find(community_id))
       .set(new_community)
       .get_result::<Self>(conn)
@@ -153,14 +159,14 @@ impl Crud<CommunityForm> for Community {
 
 impl ApubObject<CommunityForm> for Community {
   fn read_from_apub_id(conn: &PgConnection, for_actor_id: &str) -> Result<Self, Error> {
-    use crate::schema::community::dsl::*;
+    use lemmy_db_schema::schema::community::dsl::*;
     community
       .filter(actor_id.eq(for_actor_id))
       .first::<Self>(conn)
   }
 
   fn upsert(conn: &PgConnection, community_form: &CommunityForm) -> Result<Community, Error> {
-    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<CommunityForm> for Community {
 
 impl Community {
   pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Self, Error> {
-    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<Self, Error> {
-    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::<Self>(conn)
@@ -195,7 +201,7 @@ impl Community {
     community_id: i32,
     new_removed: bool,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -206,7 +212,7 @@ impl Community {
     for_creator_id: i32,
     new_removed: bool,
   ) -> Result<Vec<Self>, 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::<Self>(conn)
@@ -217,7 +223,7 @@ impl Community {
     community_id: i32,
     new_creator_id: i32,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -235,7 +241,7 @@ impl Community {
   }
 
   pub fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<String>, Error> {
-    use crate::schema::community::dsl::*;
+    use lemmy_db_schema::schema::community::dsl::*;
     community.select(actor_id).distinct().load::<String>(conn)
   }
 
@@ -268,7 +274,7 @@ impl Joinable<CommunityModeratorForm> for CommunityModerator {
     conn: &PgConnection,
     community_user_form: &CommunityModeratorForm,
   ) -> Result<Self, Error> {
-    use crate::schema::community_moderator::dsl::*;
+    use lemmy_db_schema::schema::community_moderator::dsl::*;
     insert_into(community_moderator)
       .values(community_user_form)
       .get_result::<Self>(conn)
@@ -278,7 +284,7 @@ impl Joinable<CommunityModeratorForm> for CommunityModerator {
     conn: &PgConnection,
     community_user_form: &CommunityModeratorForm,
   ) -> Result<usize, Error> {
-    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<CommunityModeratorForm> for CommunityModerator {
 
 impl CommunityModerator {
   pub fn delete_for_community(conn: &PgConnection, for_community_id: i32) -> Result<usize, Error> {
-    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<Vec<i32>, 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<CommunityUserBanForm> for CommunityUserBan {
     conn: &PgConnection,
     community_user_ban_form: &CommunityUserBanForm,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -338,7 +344,7 @@ impl Bannable<CommunityUserBanForm> for CommunityUserBan {
     conn: &PgConnection,
     community_user_ban_form: &CommunityUserBanForm,
   ) -> Result<usize, Error> {
-    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<CommunityFollowerForm> for CommunityFollower {
     conn: &PgConnection,
     community_follower_form: &CommunityFollowerForm,
   ) -> Result<Self, Error> {
-    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<CommunityFollowerForm> 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<CommunityFollowerForm> for CommunityFollower {
     conn: &PgConnection,
     community_follower_form: &CommunityFollowerForm,
   ) -> Result<usize, Error> {
-    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<CommunityFollowerForm> 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<bool, Error> {
-    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_)),
     ))
index 766c17fc57860dbafff4752206acab85b13ce1fe..0766f49cd9951d125b120b351e4ea7de93a36bb7 100644 (file)
@@ -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<ModRemovePostForm> for ModRemovePost {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use crate::schema::mod_remove_post::dsl::*;
+    use lemmy_db_schema::schema::mod_remove_post::dsl::*;
     mod_remove_post.find(from_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -76,19 +74,19 @@ pub struct ModLockPostForm {
 
 impl Crud<ModLockPostForm> for ModLockPost {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use crate::schema::mod_lock_post::dsl::*;
+    use lemmy_db_schema::schema::mod_lock_post::dsl::*;
     mod_lock_post.find(from_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -115,19 +113,19 @@ pub struct ModStickyPostForm {
 
 impl Crud<ModStickyPostForm> for ModStickyPost {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use crate::schema::mod_sticky_post::dsl::*;
+    use lemmy_db_schema::schema::mod_sticky_post::dsl::*;
     mod_sticky_post.find(from_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModStickyPostForm) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModStickyPostForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -156,19 +154,19 @@ pub struct ModRemoveCommentForm {
 
 impl Crud<ModRemoveCommentForm> for ModRemoveComment {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use crate::schema::mod_remove_comment::dsl::*;
+    use lemmy_db_schema::schema::mod_remove_comment::dsl::*;
     mod_remove_comment.find(from_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -199,12 +197,12 @@ pub struct ModRemoveCommunityForm {
 
 impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use crate::schema::mod_remove_community::dsl::*;
+    use lemmy_db_schema::schema::mod_remove_community::dsl::*;
     mod_remove_community.find(from_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -215,7 +213,7 @@ impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
     from_id: i32,
     form: &ModRemoveCommunityForm,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -248,12 +246,12 @@ pub struct ModBanFromCommunityForm {
 
 impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -264,7 +262,7 @@ impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
     from_id: i32,
     form: &ModBanFromCommunityForm,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -295,17 +293,17 @@ pub struct ModBanForm {
 
 impl Crud<ModBanForm> for ModBan {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use crate::schema::mod_ban::dsl::*;
+    use lemmy_db_schema::schema::mod_ban::dsl::*;
     mod_ban.find(from_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModBanForm) -> Result<Self, Error> {
-    use crate::schema::mod_ban::dsl::*;
+    use lemmy_db_schema::schema::mod_ban::dsl::*;
     insert_into(mod_ban).values(form).get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -334,19 +332,19 @@ pub struct ModAddCommunityForm {
 
 impl Crud<ModAddCommunityForm> for ModAddCommunity {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use crate::schema::mod_add_community::dsl::*;
+    use lemmy_db_schema::schema::mod_add_community::dsl::*;
     mod_add_community.find(from_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -373,17 +371,17 @@ pub struct ModAddForm {
 
 impl Crud<ModAddForm> for ModAdd {
   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
-    use crate::schema::mod_add::dsl::*;
+    use lemmy_db_schema::schema::mod_add::dsl::*;
     mod_add.find(from_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, form: &ModAddForm) -> Result<Self, Error> {
-    use crate::schema::mod_add::dsl::*;
+    use lemmy_db_schema::schema::mod_add::dsl::*;
     insert_into(mod_add).values(form).get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
-    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::<Self>(conn)
index 0cf0169f0ad4a18c79afd3d475d3ad5d5b0d428f..3c9969e41eaadb1dba6af3b085a2dcfc92db4e16 100644 (file)
@@ -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<PasswordResetRequestForm> for PasswordResetRequest {
   fn read(conn: &PgConnection, password_reset_request_id: i32) -> Result<Self, Error> {
-    use crate::schema::password_reset_request::dsl::*;
     password_reset_request
       .find(password_reset_request_id)
       .first::<Self>(conn)
index 098ce8835316db5a72a6c005773e3ce4a3581634..181157a21da064f3840aaa8a25e0b73b6c37c0bc 100644 (file)
@@ -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<PostForm> for Post {
   fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
-    use crate::schema::post::dsl::*;
+    use lemmy_db_schema::schema::post::dsl::*;
     post.find(post_id).first::<Self>(conn)
   }
 
   fn delete(conn: &PgConnection, post_id: i32) -> Result<usize, Error> {
-    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<Self, Error> {
-    use crate::schema::post::dsl::*;
+    use lemmy_db_schema::schema::post::dsl::*;
     insert_into(post).values(new_post).get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, post_id: i32, new_post: &PostForm) -> Result<Self, Error> {
-    use crate::schema::post::dsl::*;
+    use lemmy_db_schema::schema::post::dsl::*;
     diesel::update(post.find(post_id))
       .set(new_post)
       .get_result::<Self>(conn)
@@ -90,12 +83,12 @@ impl Crud<PostForm> for Post {
 
 impl ApubObject<PostForm> for Post {
   fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result<Self, Error> {
-    use crate::schema::post::dsl::*;
+    use lemmy_db_schema::schema::post::dsl::*;
     post.filter(ap_id.eq(object_id)).first::<Self>(conn)
   }
 
   fn upsert(conn: &PgConnection, post_form: &PostForm) -> Result<Post, Error> {
-    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<PostForm> for Post {
 
 impl Post {
   pub fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
-    use crate::schema::post::dsl::*;
+    use lemmy_db_schema::schema::post::dsl::*;
     post.filter(id.eq(post_id)).first::<Self>(conn)
   }
 
@@ -115,7 +108,7 @@ impl Post {
     conn: &PgConnection,
     the_community_id: i32,
   ) -> Result<Vec<Self>, 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<Self, Error> {
-    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<Vec<Self>, 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<Self, Error> {
-    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::<Self>(conn)
@@ -168,7 +161,7 @@ impl Post {
     post_id: i32,
     new_removed: bool,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -180,7 +173,7 @@ impl Post {
     for_community_id: Option<i32>,
     new_removed: bool,
   ) -> Result<Vec<Self>, 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<Self, Error> {
-    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::<Self>(conn)
@@ -206,7 +199,7 @@ impl Post {
     post_id: i32,
     new_stickied: bool,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -238,7 +231,7 @@ pub struct PostLikeForm {
 
 impl Likeable<PostLikeForm> for PostLike {
   fn like(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result<Self, Error> {
-    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<PostLikeForm> for PostLike {
       .get_result::<Self>(conn)
   }
   fn remove(conn: &PgConnection, user_id: i32, post_id: i32) -> Result<usize, Error> {
-    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<PostSavedForm> for PostSaved {
   fn save(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
-    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<PostSavedForm> for PostSaved {
       .get_result::<Self>(conn)
   }
   fn unsave(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<usize, Error> {
-    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<PostReadForm> for PostRead {
   fn mark_as_read(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<Self, Error> {
-    use crate::schema::post_read::dsl::*;
+    use lemmy_db_schema::schema::post_read::dsl::*;
     insert_into(post_read)
       .values(post_read_form)
       .get_result::<Self>(conn)
   }
 
   fn mark_as_unread(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<usize, Error> {
-    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))
index 6de82a2578862449bae74734d7a0add044d3b4d1..af45aa3d03e9d792a36f8ee27fcd014f91149f99 100644 (file)
@@ -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<PostReportForm> for PostReport {
   /// * `conn` - the postgres connection
   /// * `post_report_form` - the filled CommentReportForm to insert
   fn report(conn: &PgConnection, post_report_form: &PostReportForm) -> Result<Self, Error> {
-    use crate::schema::post_report::dsl::*;
+    use lemmy_db_schema::schema::post_report::dsl::*;
     insert_into(post_report)
       .values(post_report_form)
       .get_result::<Self>(conn)
@@ -49,7 +49,7 @@ impl Reportable<PostReportForm> 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<usize, Error> {
-    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<PostReportForm> 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<usize, Error> {
-    use crate::schema::post_report::dsl::*;
+    use lemmy_db_schema::schema::post_report::dsl::*;
     update(post_report.find(report_id))
       .set((
         resolved.eq(false),
index f474cf9ac303d3607b6a2de940151bcac0df116b..e2b55c8798eae0f83dc33229d7d8338bccf2eedd 100644 (file)
@@ -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<PrivateMessageForm> for PrivateMessage {
   fn read(conn: &PgConnection, private_message_id: i32) -> Result<Self, Error> {
-    use crate::schema::private_message::dsl::*;
+    use lemmy_db_schema::schema::private_message::dsl::*;
     private_message.find(private_message_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, private_message_form: &PrivateMessageForm) -> Result<Self, Error> {
-    use crate::schema::private_message::dsl::*;
+    use lemmy_db_schema::schema::private_message::dsl::*;
     insert_into(private_message)
       .values(private_message_form)
       .get_result::<Self>(conn)
@@ -49,7 +50,7 @@ impl Crud<PrivateMessageForm> for PrivateMessage {
     private_message_id: i32,
     private_message_form: &PrivateMessageForm,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -61,14 +62,14 @@ impl ApubObject<PrivateMessageForm> 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::<Self>(conn)
   }
 
   fn upsert(conn: &PgConnection, private_message_form: &PrivateMessageForm) -> Result<Self, Error> {
-    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<Self, Error> {
-    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<Self, Error> {
-    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::<Self>(conn)
@@ -107,7 +108,7 @@ impl PrivateMessage {
     private_message_id: i32,
     new_deleted: bool,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -118,14 +119,14 @@ impl PrivateMessage {
     private_message_id: i32,
     new_read: bool,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   pub fn mark_all_as_read(conn: &PgConnection, for_recipient_id: i32) -> Result<Vec<Self>, 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))
index 2f3fbcdff15859930d23a1676b3397295fa5e65a..ad6f9ea6faa8428f06014477348f929344351285 100644 (file)
@@ -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<SiteForm> for Site {
   fn read(conn: &PgConnection, _site_id: i32) -> Result<Self, Error> {
-    use crate::schema::site::dsl::*;
+    use lemmy_db_schema::schema::site::dsl::*;
     site.first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, new_site: &SiteForm) -> Result<Self, Error> {
-    use crate::schema::site::dsl::*;
+    use lemmy_db_schema::schema::site::dsl::*;
     insert_into(site).values(new_site).get_result::<Self>(conn)
   }
 
   fn update(conn: &PgConnection, site_id: i32, new_site: &SiteForm) -> Result<Self, Error> {
-    use crate::schema::site::dsl::*;
+    use lemmy_db_schema::schema::site::dsl::*;
     diesel::update(site.find(site_id))
       .set(new_site)
       .get_result::<Self>(conn)
@@ -54,7 +55,7 @@ impl Crud<SiteForm> for Site {
 
 impl Site {
   pub fn transfer(conn: &PgConnection, new_creator_id: i32) -> Result<Self, Error> {
-    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::<Self>(conn)
index 601e6e8c680f261f56a89d06329bf0bee9355417..809a579afb31f21dfb7ea32ac01df6890bd7d8c7 100644 (file)
@@ -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<UserForm> for User_ {
 
 impl ApubObject<UserForm> for User_ {
   fn read_from_apub_id(conn: &PgConnection, object_id: &str) -> Result<Self, Error> {
-    use crate::schema::user_::dsl::*;
+    use lemmy_db_schema::schema::user_::dsl::*;
     user_
       .filter(deleted.eq(false))
       .filter(actor_id.eq(object_id))
index bf53cb4200504854fbdaecce9515158fe1eec54a..a61d08d2c13213322efa75d1dba891095999492e 100644 (file)
@@ -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<UserMentionForm> for UserMention {
   fn read(conn: &PgConnection, user_mention_id: i32) -> Result<Self, Error> {
-    use crate::schema::user_mention::dsl::*;
+    use lemmy_db_schema::schema::user_mention::dsl::*;
     user_mention.find(user_mention_id).first::<Self>(conn)
   }
 
   fn create(conn: &PgConnection, user_mention_form: &UserMentionForm) -> Result<Self, Error> {
-    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<UserMentionForm> for UserMention {
     user_mention_id: i32,
     user_mention_form: &UserMentionForm,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
@@ -58,14 +59,14 @@ impl UserMention {
     user_mention_id: i32,
     new_read: bool,
   ) -> Result<Self, Error> {
-    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::<Self>(conn)
   }
 
   pub fn mark_all_as_read(conn: &PgConnection, for_recipient_id: i32) -> Result<Vec<Self>, 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))
index 540bb756988b036f6b65389f82d10469c20f9101..0f55b43200e18bbd43a8512caad9a96b85a23198 100644 (file)
@@ -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)]
index d85f654fb815e97d6e5d771c8a58325ff1e4b672..7f78c20f8b280456922f2cffd1aa64a608909547 100644 (file)
@@ -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)]
index 7de9cc3a4b92fea761b20f7041323280051ba92e..243b91420ef3dbd53b7c08f0dae381d7441f7cfd 100644 (file)
@@ -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)]
index 751e46232c715a697f1afa16c0bf66652d146f80..8762b97500571b6210968fef988baa0af90e1498 100644 (file)
@@ -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)]
index 3358f01b2d0e5b42cc09706d7ecd3cea967eb4a2..5dba4ebd305d387bc3071bc4391a6f577ca593c2 100644 (file)
@@ -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)]
index fcc707c0682b0ae178630e5bf742a73bdb9e640b..6c951b33722bb13794e0b09778108906bda41b39 100644 (file)
@@ -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)]
index 402c5fe1b29d81df411c4d4e71636c8e1220e70b..1dd7cfc471595c43a85d626e96d4a0000e043b0b 100644 (file)
@@ -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)]
index fc1993d4542865b3ebec7be3844e4f7fd4dde46c..06648ad7685258aa84159ae10b5792e754c7a88b 100644 (file)
@@ -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)]
index 6ad232e875bda7460736b6efee15ebdb16e08537..3992518bc0258e6b5a946b47711b196cccd0e804 100644 (file)
@@ -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)]
index 28214d2da1fe30086689bccb167c2bd02ab621b5..52e890259ea7eec98934ad823e9c966acb7eb8d3 100644 (file)
@@ -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)]
index 8182b54f755e85f1a78b9e40076f0d595d5e37fb..2d71a8819ba309790391f6dd4e64f1c18802ad76 100644 (file)
@@ -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)]
index fb4b7772417e26512a61c3fa78edd823bfb49c53..4fa82eed2bcfb7432f79392b13e6fd0a43e63692 100644 (file)
@@ -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)]
index daaf6d78f33c397d12a71a88f28b4ab028c2463b..1700ac2d99bebe7ac509be02ddefb2a6bece330f 100644 (file)
@@ -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)]
index 613a8a5414e275a44e60a48f286ed5aaa233f60c..d21e985cdde6a418b5af351e193dff74fa056158 100644 (file)
@@ -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)]
index 9a3d118b9f369d869010c007556f033a1cfbfb2b..ec277159297873c36a657c3ad9b100f430147c2e 100644 (file)
@@ -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)]
index d39adfd5ce67466992b70766b5de5fd6526340f3..75bfac954957c811d2e959f70ca4989b391bb67d 100644 (file)
@@ -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)]
index f95cf1184ab131f726ddcc9b5c895e4cda9e2e1f..25d86aa1600d9e939fd69bc9a3e5fc842233d587 100644 (file)
@@ -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)]
index 43d960a8af06c3180a7f8815ddff7c1511f507be..5d594b12e0383eca98f087a35279783d48f6e388 100644 (file)
@@ -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)]
index d10702fca95bb07b17af0818f5ece8c70f3376f9..d956e2e1a9761dd467e187e2a6e287460a77f684 100644 (file)
@@ -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)]
index 67616fbc33bd76a697ca13ceae999506e5149cbc..bb5fa00931938921834bbfbd1fd0802365b02fba 100644 (file)
@@ -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)]
index 587ebf617c8da777a0544d08d9be9a4d70339b85..8f59691a67c3a03e9fb82b0cd760585450859ac2 100644 (file)
@@ -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 (file)
index 0000000..3ef9755
--- /dev/null
@@ -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 (file)
index 0000000..b37d946
--- /dev/null
@@ -0,0 +1,4 @@
+#[macro_use]
+extern crate diesel;
+
+pub mod schema;
index 7a749e9b4a54c4aec610e7dfed46ffc7ff5afea0..6a39d0dadfec4bc577ba4b3493324fcccf19afd1 100644 (file)
@@ -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");