"chrono",
"diesel",
"lazy_static",
+ "lemmy_db_schema",
"lemmy_utils",
"log",
"regex",
"url",
]
+[[package]]
+name = "lemmy_db_schema"
+version = "0.1.0"
+dependencies = [
+ "diesel",
+]
+
[[package]]
name = "lemmy_rate_limit"
version = "0.1.0"
"lemmy_api",
"lemmy_apub",
"lemmy_db",
+ "lemmy_db_schema",
"lemmy_rate_limit",
"lemmy_structs",
"lemmy_utils",
"lemmy_apub",
"lemmy_utils",
"lemmy_db",
+ "lemmy_db_schema",
"lemmy_structs",
"lemmy_rate_limit",
"lemmy_websocket",
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" }
[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"] }
-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)]
-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)]
-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)]
-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)]
-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)]
use std::{env, env::VarError};
pub mod aggregates;
-pub mod schema;
pub mod source;
pub mod views;
-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;
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)
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)
}
}
}
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)
}
}
-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)]
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};
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)
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)
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)
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))
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*"),
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)
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)
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)
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)
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))
.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))
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))
.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))
+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"]
/// * `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)
/// * `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),
/// * `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),
use crate::{
naive_now,
- schema::{community, community_follower, community_moderator, community_user_ban},
views::{community::community_moderator_view::CommunityModeratorView, user_view::UserViewSafe},
ApubObject,
Bannable,
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)]
}
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,
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)
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)
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)
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))
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)
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)
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)
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)
}
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)
}
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)
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))
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)
}
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)
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)
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))
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))
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_))
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))
// 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_)),
))
-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)]
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
-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)]
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)
-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};
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)
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)
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)
}
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())
}
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))
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";
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)
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)
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));
}
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)
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)
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))
.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))
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))
.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))
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))
+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"]
/// * `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)
/// * `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),
/// * `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),
-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)]
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)
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)
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)
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))
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)
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)
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))
-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)]
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)
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)
-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;
}
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,
}
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,
}
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,
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))
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)]
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)
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)
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))
use crate::{
limit_and_offset,
- schema::{comment, comment_report, community, post, user_, user_alias_1, user_alias_2},
source::{
comment::Comment,
comment_report::CommentReport,
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)]
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},
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)]
use crate::{
- schema::{community, community_follower, user_},
source::{
community::{Community, CommunitySafe},
user::{UserSafe, User_},
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{community, community_follower, user_};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
- schema::{community, community_moderator, user_},
source::{
community::{Community, CommunitySafe},
user::{UserSafe, User_},
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{community, community_moderator, user_};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
- schema::{community, community_user_ban, user_},
source::{
community::{Community, CommunitySafe},
user::{UserSafe, User_},
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{community, community_user_ban, user_};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
functions::hot_rank,
fuzzy_search,
limit_and_offset,
- schema::{category, community, community_aggregates, community_follower, user_},
source::{
category::Category,
community::{Community, CommunityFollower, CommunitySafe},
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{
+ category,
+ community,
+ community_aggregates,
+ community_follower,
+ user_,
+};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
limit_and_offset,
- schema::{community, mod_add_community, user_, user_alias_1},
source::{
community::{Community, CommunitySafe},
moderator::ModAddCommunity,
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)]
use crate::{
limit_and_offset,
- schema::{mod_add, user_, user_alias_1},
source::{
moderator::ModAdd,
user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{mod_add, user_, user_alias_1};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
limit_and_offset,
- schema::{community, mod_ban_from_community, user_, user_alias_1},
source::{
community::{Community, CommunitySafe},
moderator::ModBanFromCommunity,
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)]
use crate::{
limit_and_offset,
- schema::{mod_ban, user_, user_alias_1},
source::{
moderator::ModBan,
user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{mod_ban, user_, user_alias_1};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
limit_and_offset,
- schema::{community, mod_lock_post, post, user_},
source::{
community::{Community, CommunitySafe},
moderator::ModLockPost,
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{community, mod_lock_post, post, user_};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
limit_and_offset,
- schema::{comment, community, mod_remove_comment, post, user_, user_alias_1},
source::{
comment::Comment,
community::{Community, CommunitySafe},
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)]
use crate::{
limit_and_offset,
- schema::{community, mod_remove_community, user_},
source::{
community::{Community, CommunitySafe},
moderator::ModRemoveCommunity,
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{community, mod_remove_community, user_};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
limit_and_offset,
- schema::{community, mod_remove_post, post, user_},
source::{
community::{Community, CommunitySafe},
moderator::ModRemovePost,
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{community, mod_remove_post, post, user_};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
limit_and_offset,
- schema::{community, mod_sticky_post, post, user_},
source::{
community::{Community, CommunitySafe},
moderator::ModStickyPost,
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{community, mod_sticky_post, post, user_};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
use crate::{
limit_and_offset,
- schema::{community, post, post_report, user_, user_alias_1, user_alias_2},
source::{
community::{Community, CommunitySafe},
post::Post,
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)]
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},
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)]
use crate::{
limit_and_offset,
- schema::{private_message, user_, user_alias_1},
source::{
private_message::PrivateMessage,
user::{UserAlias1, UserSafe, UserSafeAlias1, User_},
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{private_message, user_, user_alias_1};
use serde::Serialize;
#[derive(Debug, PartialEq, Serialize, Clone)]
use crate::{
- schema::{site, user_},
source::{
site::Site,
user::{UserSafe, User_},
ToSafe,
};
use diesel::{result::Error, *};
+use lemmy_db_schema::schema::{site, user_};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
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},
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)]
aggregates::user_aggregates::UserAggregates,
fuzzy_search,
limit_and_offset,
- schema::{user_, user_aggregates},
source::user::{UserSafe, User_},
views::ViewToVec,
MaybeOptional,
ToSafe,
};
use diesel::{dsl::*, result::Error, *};
+use lemmy_db_schema::schema::{user_, user_aggregates};
use serde::Serialize;
#[derive(Debug, Serialize, Clone)]
--- /dev/null
+[package]
+name = "lemmy_db_schema"
+version = "0.1.0"
+edition = "2018"
+
+[dependencies]
+diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
--- /dev/null
+#[macro_use]
+extern crate diesel;
+
+pub mod schema;
}
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");
}
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");
}
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");
}
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");
}
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");
}
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");