mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-25 22:10:20 +00:00
Move aliases to db_schema
This commit is contained in:
parent
d3d309cab3
commit
69afed05c1
33 changed files with 161 additions and 154 deletions
5
crates/db_schema/src/aliases.rs
Normal file
5
crates/db_schema/src/aliases.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
use crate::schema::person;
|
||||||
|
|
||||||
|
diesel::alias! {
|
||||||
|
const PERSON_1 = person as person_1: Person1, person as person_2: Person2
|
||||||
|
};
|
|
@ -28,6 +28,8 @@ pub mod newtypes;
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[allow(clippy::wildcard_imports)]
|
#[allow(clippy::wildcard_imports)]
|
||||||
pub mod schema;
|
pub mod schema;
|
||||||
|
#[cfg(feature = "full")]
|
||||||
|
pub mod aliases;
|
||||||
pub mod source;
|
pub mod source;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
pub mod traits;
|
pub mod traits;
|
||||||
|
|
|
@ -14,6 +14,7 @@ use diesel_async::RunQueryDsl;
|
||||||
use futures::future::{BoxFuture, FutureExt};
|
use futures::future::{BoxFuture, FutureExt};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
aggregates::structs::CommentAggregates,
|
aggregates::structs::CommentAggregates,
|
||||||
|
aliases,
|
||||||
newtypes::{CommentReportId, CommunityId, PersonId},
|
newtypes::{CommentReportId, CommunityId, PersonId},
|
||||||
schema::{
|
schema::{
|
||||||
comment,
|
comment,
|
||||||
|
@ -37,9 +38,6 @@ use lemmy_db_schema::{
|
||||||
utils::{get_conn, limit_and_offset, DbConn, DbPool},
|
utils::{get_conn, limit_and_offset, DbConn, DbPool},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
diesel::alias!(person as person_alias_1: PersonAlias1, person as person_alias_2:PersonAlias2);
|
|
||||||
|
|
||||||
fn queries<'a>() -> (
|
fn queries<'a>() -> (
|
||||||
impl Fn(
|
impl Fn(
|
||||||
DbConn<'a>,
|
DbConn<'a>,
|
||||||
|
@ -60,7 +58,7 @@ fn queries<'a>() -> (
|
||||||
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person::table.on(comment_report::creator_id.eq(person::id)))
|
.inner_join(person::table.on(comment_report::creator_id.eq(person::id)))
|
||||||
.inner_join(person_alias_1.on(comment::creator_id.eq(person_alias_1.field(person::id))))
|
.inner_join(aliases::person_1.on(comment::creator_id.eq(aliases::person_1.field(person::id))))
|
||||||
.inner_join(
|
.inner_join(
|
||||||
comment_aggregates::table.on(comment_report::comment_id.eq(comment_aggregates::comment_id)),
|
comment_aggregates::table.on(comment_report::comment_id.eq(comment_aggregates::comment_id)),
|
||||||
)
|
)
|
||||||
|
@ -86,8 +84,8 @@ fn queries<'a>() -> (
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.left_join(
|
.left_join(
|
||||||
person_alias_2
|
aliases::person_2
|
||||||
.on(comment_report::resolver_id.eq(person_alias_2.field(person::id).nullable())),
|
.on(comment_report::resolver_id.eq(aliases::person_2.field(person::id).nullable())),
|
||||||
)
|
)
|
||||||
.select((
|
.select((
|
||||||
comment_report::all_columns,
|
comment_report::all_columns,
|
||||||
|
@ -95,11 +93,11 @@ fn queries<'a>() -> (
|
||||||
post::all_columns,
|
post::all_columns,
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
comment_aggregates::all_columns,
|
comment_aggregates::all_columns,
|
||||||
community_person_ban::all_columns.nullable(),
|
community_person_ban::all_columns.nullable(),
|
||||||
comment_like::score.nullable(),
|
comment_like::score.nullable(),
|
||||||
person_alias_2.fields(person::all_columns).nullable(),
|
aliases::person_2.fields(person::all_columns).nullable(),
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
let read = move |mut conn: DbConn<'a>, report_id: CommentReportId, my_person_id: PersonId| {
|
let read = move |mut conn: DbConn<'a>, report_id: CommentReportId, my_person_id: PersonId| {
|
||||||
|
@ -130,7 +128,6 @@ fn queries<'a>() -> (
|
||||||
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
|
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
|
||||||
|
|
||||||
query = query
|
query = query
|
||||||
|
|
||||||
.order_by(comment_report::published.desc())
|
.order_by(comment_report::published.desc())
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset);
|
.offset(offset);
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
aggregates::structs::PostAggregates,
|
aggregates::structs::PostAggregates,
|
||||||
|
aliases,
|
||||||
newtypes::{CommunityId, PersonId, PostReportId},
|
newtypes::{CommunityId, PersonId, PostReportId},
|
||||||
schema::{
|
schema::{
|
||||||
community,
|
community,
|
||||||
|
@ -53,7 +54,6 @@ impl PostReportView {
|
||||||
my_person_id: PersonId,
|
my_person_id: PersonId,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
|
|
||||||
|
|
||||||
let (
|
let (
|
||||||
post_report,
|
post_report,
|
||||||
|
@ -70,7 +70,7 @@ impl PostReportView {
|
||||||
.inner_join(post::table)
|
.inner_join(post::table)
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person::table.on(post_report::creator_id.eq(person::id)))
|
.inner_join(person::table.on(post_report::creator_id.eq(person::id)))
|
||||||
.inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id))))
|
.inner_join(aliases::person_1.on(post::creator_id.eq(aliases::person_1.field(person::id))))
|
||||||
.left_join(
|
.left_join(
|
||||||
community_person_ban::table.on(
|
community_person_ban::table.on(
|
||||||
post::community_id
|
post::community_id
|
||||||
|
@ -87,18 +87,19 @@ impl PostReportView {
|
||||||
)
|
)
|
||||||
.inner_join(post_aggregates::table.on(post_report::post_id.eq(post_aggregates::post_id)))
|
.inner_join(post_aggregates::table.on(post_report::post_id.eq(post_aggregates::post_id)))
|
||||||
.left_join(
|
.left_join(
|
||||||
person_alias_2.on(post_report::resolver_id.eq(person_alias_2.field(person::id).nullable())),
|
aliases::person_2
|
||||||
|
.on(post_report::resolver_id.eq(aliases::person_2.field(person::id).nullable())),
|
||||||
)
|
)
|
||||||
.select((
|
.select((
|
||||||
post_report::all_columns,
|
post_report::all_columns,
|
||||||
post::all_columns,
|
post::all_columns,
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
community_person_ban::all_columns.nullable(),
|
community_person_ban::all_columns.nullable(),
|
||||||
post_like::score.nullable(),
|
post_like::score.nullable(),
|
||||||
post_aggregates::all_columns,
|
post_aggregates::all_columns,
|
||||||
person_alias_2.fields(person::all_columns.nullable()),
|
aliases::person_2.fields(person::all_columns.nullable()),
|
||||||
))
|
))
|
||||||
.first::<PostReportViewTuple>(conn)
|
.first::<PostReportViewTuple>(conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -173,13 +174,12 @@ impl PostReportQuery {
|
||||||
my_person: &Person,
|
my_person: &Person,
|
||||||
) -> Result<Vec<PostReportView>, Error> {
|
) -> Result<Vec<PostReportView>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
|
|
||||||
|
|
||||||
let mut query = post_report::table
|
let mut query = post_report::table
|
||||||
.inner_join(post::table)
|
.inner_join(post::table)
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person::table.on(post_report::creator_id.eq(person::id)))
|
.inner_join(person::table.on(post_report::creator_id.eq(person::id)))
|
||||||
.inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id))))
|
.inner_join(aliases::person_1.on(post::creator_id.eq(aliases::person_1.field(person::id))))
|
||||||
.left_join(
|
.left_join(
|
||||||
community_person_ban::table.on(
|
community_person_ban::table.on(
|
||||||
post::community_id
|
post::community_id
|
||||||
|
@ -196,18 +196,19 @@ impl PostReportQuery {
|
||||||
)
|
)
|
||||||
.inner_join(post_aggregates::table.on(post_report::post_id.eq(post_aggregates::post_id)))
|
.inner_join(post_aggregates::table.on(post_report::post_id.eq(post_aggregates::post_id)))
|
||||||
.left_join(
|
.left_join(
|
||||||
person_alias_2.on(post_report::resolver_id.eq(person_alias_2.field(person::id).nullable())),
|
aliases::person_2
|
||||||
|
.on(post_report::resolver_id.eq(aliases::person_2.field(person::id).nullable())),
|
||||||
)
|
)
|
||||||
.select((
|
.select((
|
||||||
post_report::all_columns,
|
post_report::all_columns,
|
||||||
post::all_columns,
|
post::all_columns,
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
community_person_ban::all_columns.nullable(),
|
community_person_ban::all_columns.nullable(),
|
||||||
post_like::score.nullable(),
|
post_like::score.nullable(),
|
||||||
post_aggregates::all_columns,
|
post_aggregates::all_columns,
|
||||||
person_alias_2.fields(person::all_columns.nullable()),
|
aliases::person_2.fields(person::all_columns.nullable()),
|
||||||
))
|
))
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ use crate::structs::PrivateMessageReportView;
|
||||||
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, QueryDsl};
|
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PrivateMessageReportId,
|
newtypes::PrivateMessageReportId,
|
||||||
schema::{person, private_message, private_message_report},
|
schema::{person, private_message, private_message_report},
|
||||||
source::{
|
source::{
|
||||||
|
@ -30,7 +31,6 @@ impl PrivateMessageReportView {
|
||||||
report_id: PrivateMessageReportId,
|
report_id: PrivateMessageReportId,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
|
|
||||||
|
|
||||||
let (private_message_report, private_message, private_message_creator, creator, resolver) =
|
let (private_message_report, private_message, private_message_creator, creator, resolver) =
|
||||||
private_message_report::table
|
private_message_report::table
|
||||||
|
@ -38,20 +38,18 @@ impl PrivateMessageReportView {
|
||||||
.inner_join(private_message::table)
|
.inner_join(private_message::table)
|
||||||
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
||||||
.inner_join(
|
.inner_join(
|
||||||
person_alias_1
|
aliases::person_1
|
||||||
.on(private_message_report::creator_id.eq(person_alias_1.field(person::id))),
|
.on(private_message_report::creator_id.eq(aliases::person_1.field(person::id))),
|
||||||
)
|
|
||||||
.left_join(
|
|
||||||
person_alias_2.on(
|
|
||||||
private_message_report::resolver_id.eq(person_alias_2.field(person::id).nullable()),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
.left_join(aliases::person_2.on(
|
||||||
|
private_message_report::resolver_id.eq(aliases::person_2.field(person::id).nullable()),
|
||||||
|
))
|
||||||
.select((
|
.select((
|
||||||
private_message_report::all_columns,
|
private_message_report::all_columns,
|
||||||
private_message::all_columns,
|
private_message::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
person_alias_2.fields(person::all_columns).nullable(),
|
aliases::person_2.fields(person::all_columns).nullable(),
|
||||||
))
|
))
|
||||||
.first::<PrivateMessageReportViewTuple>(conn)
|
.first::<PrivateMessageReportViewTuple>(conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -90,26 +88,26 @@ pub struct PrivateMessageReportQuery {
|
||||||
impl PrivateMessageReportQuery {
|
impl PrivateMessageReportQuery {
|
||||||
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<PrivateMessageReportView>, Error> {
|
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<PrivateMessageReportView>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
|
|
||||||
|
|
||||||
let mut query = private_message_report::table
|
let mut query =
|
||||||
.inner_join(private_message::table)
|
private_message_report::table
|
||||||
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
.inner_join(private_message::table)
|
||||||
.inner_join(
|
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
||||||
person_alias_1.on(private_message_report::creator_id.eq(person_alias_1.field(person::id))),
|
.inner_join(
|
||||||
)
|
aliases::person_1
|
||||||
.left_join(
|
.on(private_message_report::creator_id.eq(aliases::person_1.field(person::id))),
|
||||||
person_alias_2
|
)
|
||||||
.on(private_message_report::resolver_id.eq(person_alias_2.field(person::id).nullable())),
|
.left_join(aliases::person_2.on(
|
||||||
)
|
private_message_report::resolver_id.eq(aliases::person_2.field(person::id).nullable()),
|
||||||
.select((
|
))
|
||||||
private_message_report::all_columns,
|
.select((
|
||||||
private_message::all_columns,
|
private_message_report::all_columns,
|
||||||
person::all_columns,
|
private_message::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
person::all_columns,
|
||||||
person_alias_2.fields(person::all_columns).nullable(),
|
aliases::person_1.fields(person::all_columns),
|
||||||
))
|
aliases::person_2.fields(person::all_columns).nullable(),
|
||||||
.into_boxed();
|
))
|
||||||
|
.into_boxed();
|
||||||
|
|
||||||
if self.unresolved_only.unwrap_or(false) {
|
if self.unresolved_only.unwrap_or(false) {
|
||||||
query = query.filter(private_message_report::resolved.eq(false));
|
query = query.filter(private_message_report::resolved.eq(false));
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::{PersonId, PrivateMessageId},
|
newtypes::{PersonId, PrivateMessageId},
|
||||||
schema::{person, private_message},
|
schema::{person, private_message},
|
||||||
source::{person::Person, private_message::PrivateMessage},
|
source::{person::Person, private_message::PrivateMessage},
|
||||||
|
@ -26,19 +27,18 @@ impl PrivateMessageView {
|
||||||
private_message_id: PrivateMessageId,
|
private_message_id: PrivateMessageId,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
let (private_message, creator, recipient) = private_message::table
|
let (private_message, creator, recipient) = private_message::table
|
||||||
.find(private_message_id)
|
.find(private_message_id)
|
||||||
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
||||||
.inner_join(
|
.inner_join(
|
||||||
person_alias_1.on(private_message::recipient_id.eq(person_alias_1.field(person::id))),
|
aliases::person_1.on(private_message::recipient_id.eq(aliases::person_1.field(person::id))),
|
||||||
)
|
)
|
||||||
.order_by(private_message::published.desc())
|
.order_by(private_message::published.desc())
|
||||||
.select((
|
.select((
|
||||||
private_message::all_columns,
|
private_message::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
))
|
))
|
||||||
.first::<PrivateMessageViewTuple>(conn)
|
.first::<PrivateMessageViewTuple>(conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -81,17 +81,16 @@ impl PrivateMessageQuery {
|
||||||
recipient_id: PersonId,
|
recipient_id: PersonId,
|
||||||
) -> Result<Vec<PrivateMessageView>, Error> {
|
) -> Result<Vec<PrivateMessageView>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
let mut query = private_message::table
|
let mut query = private_message::table
|
||||||
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
||||||
.inner_join(
|
.inner_join(
|
||||||
person_alias_1.on(private_message::recipient_id.eq(person_alias_1.field(person::id))),
|
aliases::person_1.on(private_message::recipient_id.eq(aliases::person_1.field(person::id))),
|
||||||
)
|
)
|
||||||
.select((
|
.select((
|
||||||
private_message::all_columns,
|
private_message::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
))
|
))
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
schema::{local_user, person, registration_application},
|
schema::{local_user, person, registration_application},
|
||||||
source::{
|
source::{
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
|
@ -28,7 +29,6 @@ impl RegistrationApplicationView {
|
||||||
registration_application_id: i32,
|
registration_application_id: i32,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
let (registration_application, creator_local_user, creator, admin) =
|
let (registration_application, creator_local_user, creator, admin) =
|
||||||
registration_application::table
|
registration_application::table
|
||||||
|
@ -37,16 +37,15 @@ impl RegistrationApplicationView {
|
||||||
local_user::table.on(registration_application::local_user_id.eq(local_user::id)),
|
local_user::table.on(registration_application::local_user_id.eq(local_user::id)),
|
||||||
)
|
)
|
||||||
.inner_join(person::table.on(local_user::person_id.eq(person::id)))
|
.inner_join(person::table.on(local_user::person_id.eq(person::id)))
|
||||||
.left_join(
|
.left_join(aliases::person_1.on(
|
||||||
person_alias_1
|
registration_application::admin_id.eq(aliases::person_1.field(person::id).nullable()),
|
||||||
.on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())),
|
))
|
||||||
)
|
|
||||||
.order_by(registration_application::published.desc())
|
.order_by(registration_application::published.desc())
|
||||||
.select((
|
.select((
|
||||||
registration_application::all_columns,
|
registration_application::all_columns,
|
||||||
local_user::all_columns,
|
local_user::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_alias_1.fields(person::all_columns).nullable(),
|
aliases::person_1.fields(person::all_columns).nullable(),
|
||||||
))
|
))
|
||||||
.first::<RegistrationApplicationViewTuple>(conn)
|
.first::<RegistrationApplicationViewTuple>(conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -65,14 +64,14 @@ impl RegistrationApplicationView {
|
||||||
verified_email_only: bool,
|
verified_email_only: bool,
|
||||||
) -> Result<i64, Error> {
|
) -> Result<i64, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
let mut query = registration_application::table
|
let mut query = registration_application::table
|
||||||
.inner_join(local_user::table.on(registration_application::local_user_id.eq(local_user::id)))
|
.inner_join(local_user::table.on(registration_application::local_user_id.eq(local_user::id)))
|
||||||
.inner_join(person::table.on(local_user::person_id.eq(person::id)))
|
.inner_join(person::table.on(local_user::person_id.eq(person::id)))
|
||||||
.left_join(
|
.left_join(
|
||||||
person_alias_1
|
aliases::person_1.on(
|
||||||
.on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())),
|
registration_application::admin_id.eq(aliases::person_1.field(person::id).nullable()),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.filter(registration_application::admin_id.is_null())
|
.filter(registration_application::admin_id.is_null())
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
@ -102,21 +101,21 @@ impl RegistrationApplicationQuery {
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
) -> Result<Vec<RegistrationApplicationView>, Error> {
|
) -> Result<Vec<RegistrationApplicationView>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
let mut query = registration_application::table
|
let mut query = registration_application::table
|
||||||
.inner_join(local_user::table.on(registration_application::local_user_id.eq(local_user::id)))
|
.inner_join(local_user::table.on(registration_application::local_user_id.eq(local_user::id)))
|
||||||
.inner_join(person::table.on(local_user::person_id.eq(person::id)))
|
.inner_join(person::table.on(local_user::person_id.eq(person::id)))
|
||||||
.left_join(
|
.left_join(
|
||||||
person_alias_1
|
aliases::person_1.on(
|
||||||
.on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())),
|
registration_application::admin_id.eq(aliases::person_1.field(person::id).nullable()),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.order_by(registration_application::published.desc())
|
.order_by(registration_application::published.desc())
|
||||||
.select((
|
.select((
|
||||||
registration_application::all_columns,
|
registration_application::all_columns,
|
||||||
local_user::all_columns,
|
local_user::all_columns,
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
person_alias_1.fields(person::all_columns).nullable(),
|
aliases::person_1.fields(person::all_columns).nullable(),
|
||||||
))
|
))
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
aggregates::structs::CommentAggregates,
|
aggregates::structs::CommentAggregates,
|
||||||
|
aliases,
|
||||||
newtypes::{CommentReplyId, PersonId},
|
newtypes::{CommentReplyId, PersonId},
|
||||||
schema::{
|
schema::{
|
||||||
comment,
|
comment,
|
||||||
|
@ -59,7 +60,6 @@ impl CommentReplyView {
|
||||||
my_person_id: Option<PersonId>,
|
my_person_id: Option<PersonId>,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
// The left join below will return None in this case
|
// The left join below will return None in this case
|
||||||
let person_id_join = my_person_id.unwrap_or(PersonId(-1));
|
let person_id_join = my_person_id.unwrap_or(PersonId(-1));
|
||||||
|
@ -83,7 +83,7 @@ impl CommentReplyView {
|
||||||
.inner_join(person::table.on(comment::creator_id.eq(person::id)))
|
.inner_join(person::table.on(comment::creator_id.eq(person::id)))
|
||||||
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person_alias_1)
|
.inner_join(aliases::person_1)
|
||||||
.inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id)))
|
.inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id)))
|
||||||
.left_join(
|
.left_join(
|
||||||
community_person_ban::table.on(
|
community_person_ban::table.on(
|
||||||
|
@ -126,7 +126,7 @@ impl CommentReplyView {
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
post::all_columns,
|
post::all_columns,
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
comment_aggregates::all_columns,
|
comment_aggregates::all_columns,
|
||||||
community_person_ban::all_columns.nullable(),
|
community_person_ban::all_columns.nullable(),
|
||||||
community_follower::all_columns.nullable(),
|
community_follower::all_columns.nullable(),
|
||||||
|
@ -189,8 +189,6 @@ impl CommentReplyQuery {
|
||||||
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<CommentReplyView>, Error> {
|
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<CommentReplyView>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
// The left join below will return None in this case
|
// The left join below will return None in this case
|
||||||
let person_id_join = self.my_person_id.unwrap_or(PersonId(-1));
|
let person_id_join = self.my_person_id.unwrap_or(PersonId(-1));
|
||||||
|
|
||||||
|
@ -199,7 +197,7 @@ impl CommentReplyQuery {
|
||||||
.inner_join(person::table.on(comment::creator_id.eq(person::id)))
|
.inner_join(person::table.on(comment::creator_id.eq(person::id)))
|
||||||
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person_alias_1)
|
.inner_join(aliases::person_1)
|
||||||
.inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id)))
|
.inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id)))
|
||||||
.left_join(
|
.left_join(
|
||||||
community_person_ban::table.on(
|
community_person_ban::table.on(
|
||||||
|
@ -242,7 +240,7 @@ impl CommentReplyQuery {
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
post::all_columns,
|
post::all_columns,
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
comment_aggregates::all_columns,
|
comment_aggregates::all_columns,
|
||||||
community_person_ban::all_columns.nullable(),
|
community_person_ban::all_columns.nullable(),
|
||||||
community_follower::all_columns.nullable(),
|
community_follower::all_columns.nullable(),
|
||||||
|
|
|
@ -2,6 +2,7 @@ use crate::structs::PersonBlockView;
|
||||||
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, QueryDsl};
|
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{person, person_block},
|
schema::{person, person_block},
|
||||||
source::person::Person,
|
source::person::Person,
|
||||||
|
@ -14,7 +15,7 @@ type PersonBlockViewTuple = (Person, Person);
|
||||||
impl PersonBlockView {
|
impl PersonBlockView {
|
||||||
pub async fn for_person(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
pub async fn for_person(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let target_person_alias = diesel::alias!(person as person1);
|
let target_person_alias = aliases::person_1;
|
||||||
|
|
||||||
let res = person_block::table
|
let res = person_block::table
|
||||||
.inner_join(person::table.on(person_block::person_id.eq(person::id)))
|
.inner_join(person::table.on(person_block::person_id.eq(person::id)))
|
||||||
|
|
|
@ -11,6 +11,7 @@ use diesel::{
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
aggregates::structs::CommentAggregates,
|
aggregates::structs::CommentAggregates,
|
||||||
|
aliases,
|
||||||
newtypes::{PersonId, PersonMentionId},
|
newtypes::{PersonId, PersonMentionId},
|
||||||
schema::{
|
schema::{
|
||||||
comment,
|
comment,
|
||||||
|
@ -60,7 +61,6 @@ impl PersonMentionView {
|
||||||
my_person_id: Option<PersonId>,
|
my_person_id: Option<PersonId>,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
// The left join below will return None in this case
|
// The left join below will return None in this case
|
||||||
let person_id_join = my_person_id.unwrap_or(PersonId(-1));
|
let person_id_join = my_person_id.unwrap_or(PersonId(-1));
|
||||||
|
@ -84,7 +84,7 @@ impl PersonMentionView {
|
||||||
.inner_join(person::table.on(comment::creator_id.eq(person::id)))
|
.inner_join(person::table.on(comment::creator_id.eq(person::id)))
|
||||||
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person_alias_1)
|
.inner_join(aliases::person_1)
|
||||||
.inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id)))
|
.inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id)))
|
||||||
.left_join(
|
.left_join(
|
||||||
community_person_ban::table.on(
|
community_person_ban::table.on(
|
||||||
|
@ -127,7 +127,7 @@ impl PersonMentionView {
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
post::all_columns,
|
post::all_columns,
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
comment_aggregates::all_columns,
|
comment_aggregates::all_columns,
|
||||||
community_person_ban::all_columns.nullable(),
|
community_person_ban::all_columns.nullable(),
|
||||||
community_follower::all_columns.nullable(),
|
community_follower::all_columns.nullable(),
|
||||||
|
@ -189,8 +189,6 @@ impl PersonMentionQuery {
|
||||||
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<PersonMentionView>, Error> {
|
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<PersonMentionView>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
|
|
||||||
// The left join below will return None in this case
|
// The left join below will return None in this case
|
||||||
let person_id_join = self.my_person_id.unwrap_or(PersonId(-1));
|
let person_id_join = self.my_person_id.unwrap_or(PersonId(-1));
|
||||||
|
|
||||||
|
@ -199,7 +197,7 @@ impl PersonMentionQuery {
|
||||||
.inner_join(person::table.on(comment::creator_id.eq(person::id)))
|
.inner_join(person::table.on(comment::creator_id.eq(person::id)))
|
||||||
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person_alias_1)
|
.inner_join(aliases::person_1)
|
||||||
.inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id)))
|
.inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id)))
|
||||||
.left_join(
|
.left_join(
|
||||||
community_person_ban::table.on(
|
community_person_ban::table.on(
|
||||||
|
@ -247,7 +245,7 @@ impl PersonMentionQuery {
|
||||||
person::all_columns,
|
person::all_columns,
|
||||||
post::all_columns,
|
post::all_columns,
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
comment_aggregates::all_columns,
|
comment_aggregates::all_columns,
|
||||||
community_person_ban::all_columns.nullable(),
|
community_person_ban::all_columns.nullable(),
|
||||||
community_follower::all_columns.nullable(),
|
community_follower::all_columns.nullable(),
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{community, mod_add_community, person},
|
schema::{community, mod_add_community, person},
|
||||||
source::{community::Community, moderator::ModAddCommunity, person::Person},
|
source::{community::Community, moderator::ModAddCommunity, person::Person},
|
||||||
|
@ -22,7 +23,7 @@ type ModAddCommunityViewTuple = (ModAddCommunity, Option<Person>, Community, Per
|
||||||
impl ModAddCommunityView {
|
impl ModAddCommunityView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -34,13 +35,14 @@ impl ModAddCommunityView {
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(community::table)
|
.inner_join(community::table)
|
||||||
.inner_join(
|
.inner_join(
|
||||||
person_alias_1.on(mod_add_community::other_person_id.eq(person_alias_1.field(person::id))),
|
aliases::person_1
|
||||||
|
.on(mod_add_community::other_person_id.eq(aliases::person_1.field(person::id))),
|
||||||
)
|
)
|
||||||
.select((
|
.select((
|
||||||
mod_add_community::all_columns,
|
mod_add_community::all_columns,
|
||||||
person::all_columns.nullable(),
|
person::all_columns.nullable(),
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
))
|
))
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@ impl ModAddCommunityView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(other_person_id) = params.other_person_id {
|
if let Some(other_person_id) = params.other_person_id {
|
||||||
query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
|
query = query.filter(aliases::person_1.field(person::id).eq(other_person_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{mod_add, person},
|
schema::{mod_add, person},
|
||||||
source::{moderator::ModAdd, person::Person},
|
source::{moderator::ModAdd, person::Person},
|
||||||
|
@ -22,7 +23,7 @@ type ModAddViewTuple = (ModAdd, Option<Person>, Person);
|
||||||
impl ModAddView {
|
impl ModAddView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -32,11 +33,13 @@ impl ModAddView {
|
||||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||||
let mut query = mod_add::table
|
let mut query = mod_add::table
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(person_alias_1.on(mod_add::other_person_id.eq(person_alias_1.field(person::id))))
|
.inner_join(
|
||||||
|
aliases::person_1.on(mod_add::other_person_id.eq(aliases::person_1.field(person::id))),
|
||||||
|
)
|
||||||
.select((
|
.select((
|
||||||
mod_add::all_columns,
|
mod_add::all_columns,
|
||||||
person::all_columns.nullable(),
|
person::all_columns.nullable(),
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
))
|
))
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
|
@ -45,7 +48,7 @@ impl ModAddView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(other_person_id) = params.other_person_id {
|
if let Some(other_person_id) = params.other_person_id {
|
||||||
query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
|
query = query.filter(aliases::person_1.field(person::id).eq(other_person_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{community, mod_ban_from_community, person},
|
schema::{community, mod_ban_from_community, person},
|
||||||
source::{community::Community, moderator::ModBanFromCommunity, person::Person},
|
source::{community::Community, moderator::ModBanFromCommunity, person::Person},
|
||||||
|
@ -23,7 +24,6 @@ impl ModBanFromCommunityView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -35,14 +35,14 @@ impl ModBanFromCommunityView {
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(community::table)
|
.inner_join(community::table)
|
||||||
.inner_join(
|
.inner_join(
|
||||||
person_alias_1
|
aliases::person_1
|
||||||
.on(mod_ban_from_community::other_person_id.eq(person_alias_1.field(person::id))),
|
.on(mod_ban_from_community::other_person_id.eq(aliases::person_1.field(person::id))),
|
||||||
)
|
)
|
||||||
.select((
|
.select((
|
||||||
mod_ban_from_community::all_columns,
|
mod_ban_from_community::all_columns,
|
||||||
person::all_columns.nullable(),
|
person::all_columns.nullable(),
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
))
|
))
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{mod_ban, person},
|
schema::{mod_ban, person},
|
||||||
source::{moderator::ModBan, person::Person},
|
source::{moderator::ModBan, person::Person},
|
||||||
|
@ -22,7 +23,7 @@ type ModBanViewTuple = (ModBan, Option<Person>, Person);
|
||||||
impl ModBanView {
|
impl ModBanView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -32,11 +33,13 @@ impl ModBanView {
|
||||||
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
.and(show_mod_names_expr.or(person::id.eq(admin_person_id_join)));
|
||||||
let mut query = mod_ban::table
|
let mut query = mod_ban::table
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(person_alias_1.on(mod_ban::other_person_id.eq(person_alias_1.field(person::id))))
|
.inner_join(
|
||||||
|
aliases::person_1.on(mod_ban::other_person_id.eq(aliases::person_1.field(person::id))),
|
||||||
|
)
|
||||||
.select((
|
.select((
|
||||||
mod_ban::all_columns,
|
mod_ban::all_columns,
|
||||||
person::all_columns.nullable(),
|
person::all_columns.nullable(),
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
))
|
))
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
|
@ -45,7 +48,7 @@ impl ModBanView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(other_person_id) = params.other_person_id {
|
if let Some(other_person_id) = params.other_person_id {
|
||||||
query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
|
query = query.filter(aliases::person_1.field(person::id).eq(other_person_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{community, mod_feature_post, person, post},
|
schema::{community, mod_feature_post, person, post},
|
||||||
source::{community::Community, moderator::ModFeaturePost, person::Person, post::Post},
|
source::{community::Community, moderator::ModFeaturePost, person::Person, post::Post},
|
||||||
|
@ -22,7 +23,7 @@ type ModFeaturePostViewTuple = (ModFeaturePost, Option<Person>, Post, Community)
|
||||||
impl ModFeaturePostView {
|
impl ModFeaturePostView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -33,7 +34,7 @@ impl ModFeaturePostView {
|
||||||
let mut query = mod_feature_post::table
|
let mut query = mod_feature_post::table
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(post::table)
|
.inner_join(post::table)
|
||||||
.inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id))))
|
.inner_join(aliases::person_1.on(post::creator_id.eq(aliases::person_1.field(person::id))))
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.select((
|
.select((
|
||||||
mod_feature_post::all_columns,
|
mod_feature_post::all_columns,
|
||||||
|
@ -52,7 +53,7 @@ impl ModFeaturePostView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(other_person_id) = params.other_person_id {
|
if let Some(other_person_id) = params.other_person_id {
|
||||||
query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
|
query = query.filter(aliases::person_1.field(person::id).eq(other_person_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{community, mod_lock_post, person, post},
|
schema::{community, mod_lock_post, person, post},
|
||||||
source::{community::Community, moderator::ModLockPost, person::Person, post::Post},
|
source::{community::Community, moderator::ModLockPost, person::Person, post::Post},
|
||||||
|
@ -23,7 +24,6 @@ impl ModLockPostView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -35,7 +35,7 @@ impl ModLockPostView {
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(post::table)
|
.inner_join(post::table)
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id))))
|
.inner_join(aliases::person_1.on(post::creator_id.eq(aliases::person_1.field(person::id))))
|
||||||
.select((
|
.select((
|
||||||
mod_lock_post::all_columns,
|
mod_lock_post::all_columns,
|
||||||
person::all_columns.nullable(),
|
person::all_columns.nullable(),
|
||||||
|
@ -53,7 +53,7 @@ impl ModLockPostView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(other_person_id) = params.other_person_id {
|
if let Some(other_person_id) = params.other_person_id {
|
||||||
query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
|
query = query.filter(aliases::person_1.field(person::id).eq(other_person_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{comment, community, mod_remove_comment, person, post},
|
schema::{comment, community, mod_remove_comment, person, post},
|
||||||
source::{
|
source::{
|
||||||
|
@ -35,7 +36,6 @@ type ModRemoveCommentViewTuple = (
|
||||||
impl ModRemoveCommentView {
|
impl ModRemoveCommentView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let person_alias_1 = diesel::alias!(lemmy_db_schema::schema::person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -46,14 +46,14 @@ impl ModRemoveCommentView {
|
||||||
let mut query = mod_remove_comment::table
|
let mut query = mod_remove_comment::table
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(comment::table)
|
.inner_join(comment::table)
|
||||||
.inner_join(person_alias_1.on(comment::creator_id.eq(person_alias_1.field(person::id))))
|
.inner_join(aliases::person_1.on(comment::creator_id.eq(aliases::person_1.field(person::id))))
|
||||||
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
.inner_join(post::table.on(comment::post_id.eq(post::id)))
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.select((
|
.select((
|
||||||
mod_remove_comment::all_columns,
|
mod_remove_comment::all_columns,
|
||||||
person::all_columns.nullable(),
|
person::all_columns.nullable(),
|
||||||
comment::all_columns,
|
comment::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
post::all_columns,
|
post::all_columns,
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
))
|
))
|
||||||
|
@ -68,7 +68,7 @@ impl ModRemoveCommentView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(other_person_id) = params.other_person_id {
|
if let Some(other_person_id) = params.other_person_id {
|
||||||
query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
|
query = query.filter(aliases::person_1.field(person::id).eq(other_person_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{community, mod_remove_post, person, post},
|
schema::{community, mod_remove_post, person, post},
|
||||||
source::{community::Community, moderator::ModRemovePost, person::Person, post::Post},
|
source::{community::Community, moderator::ModRemovePost, person::Person, post::Post},
|
||||||
|
@ -23,7 +24,6 @@ impl ModRemovePostView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -35,7 +35,7 @@ impl ModRemovePostView {
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(post::table)
|
.inner_join(post::table)
|
||||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||||
.inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id))))
|
.inner_join(aliases::person_1.on(post::creator_id.eq(aliases::person_1.field(person::id))))
|
||||||
.select((
|
.select((
|
||||||
mod_remove_post::all_columns,
|
mod_remove_post::all_columns,
|
||||||
person::all_columns.nullable(),
|
person::all_columns.nullable(),
|
||||||
|
@ -53,7 +53,7 @@ impl ModRemovePostView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(other_person_id) = params.other_person_id {
|
if let Some(other_person_id) = params.other_person_id {
|
||||||
query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
|
query = query.filter(aliases::person_1.field(person::id).eq(other_person_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
aliases,
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
schema::{community, mod_transfer_community, person},
|
schema::{community, mod_transfer_community, person},
|
||||||
source::{community::Community, moderator::ModTransferCommunity, person::Person},
|
source::{community::Community, moderator::ModTransferCommunity, person::Person},
|
||||||
|
@ -23,7 +24,6 @@ impl ModTransferCommunityView {
|
||||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
let person_alias_1 = diesel::alias!(person as person1);
|
|
||||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||||
let show_mod_names = !params.hide_modlog_names;
|
let show_mod_names = !params.hide_modlog_names;
|
||||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||||
|
@ -35,14 +35,14 @@ impl ModTransferCommunityView {
|
||||||
.left_join(person::table.on(admin_names_join))
|
.left_join(person::table.on(admin_names_join))
|
||||||
.inner_join(community::table)
|
.inner_join(community::table)
|
||||||
.inner_join(
|
.inner_join(
|
||||||
person_alias_1
|
aliases::person_1
|
||||||
.on(mod_transfer_community::other_person_id.eq(person_alias_1.field(person::id))),
|
.on(mod_transfer_community::other_person_id.eq(aliases::person_1.field(person::id))),
|
||||||
)
|
)
|
||||||
.select((
|
.select((
|
||||||
mod_transfer_community::all_columns,
|
mod_transfer_community::all_columns,
|
||||||
person::all_columns.nullable(),
|
person::all_columns.nullable(),
|
||||||
community::all_columns,
|
community::all_columns,
|
||||||
person_alias_1.fields(person::all_columns),
|
aliases::person_1.fields(person::all_columns),
|
||||||
))
|
))
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ impl ModTransferCommunityView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(other_person_id) = params.other_person_id {
|
if let Some(other_person_id) = params.other_person_id {
|
||||||
query = query.filter(person_alias_1.field(person::id).eq(other_person_id));
|
query = query.filter(aliases::person_1.field(person::id).eq(other_person_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
let (limit, offset) = limit_and_offset(params.page, params.limit)?;
|
||||||
|
|
|
@ -135,7 +135,7 @@ drop function
|
||||||
|
|
||||||
-- user_ table
|
-- user_ table
|
||||||
-- Drop views
|
-- Drop views
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
|
|
||||||
-- Rename indexes
|
-- Rename indexes
|
||||||
alter index person__pkey rename to user__pkey;
|
alter index person__pkey rename to user__pkey;
|
||||||
|
|
|
@ -86,8 +86,8 @@ alter function site_aggregates_user_delete() rename to site_aggregates_person_de
|
||||||
alter function site_aggregates_user_insert() rename to site_aggregates_person_insert;
|
alter function site_aggregates_user_insert() rename to site_aggregates_person_insert;
|
||||||
|
|
||||||
-- Create views
|
-- Create views
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
||||||
-- Redo user aggregates into person_aggregates
|
-- Redo user aggregates into person_aggregates
|
||||||
alter table user_aggregates rename to person_aggregates;
|
alter table user_aggregates rename to person_aggregates;
|
||||||
|
|
|
@ -8,10 +8,10 @@ set
|
||||||
from person p
|
from person p
|
||||||
where p.id = lu.person_id;
|
where p.id = lu.person_id;
|
||||||
|
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
alter table person drop column matrix_user_id;
|
alter table person drop column matrix_user_id;
|
||||||
alter table person drop column admin;
|
alter table person drop column admin;
|
||||||
|
|
||||||
-- Regenerate the person_alias views
|
-- Regenerate the person_alias views
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
|
@ -12,6 +12,6 @@ alter table local_user drop column matrix_user_id;
|
||||||
alter table local_user drop column admin;
|
alter table local_user drop column admin;
|
||||||
|
|
||||||
-- Regenerate the person_alias views
|
-- Regenerate the person_alias views
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
alter table person drop column bot_account;
|
alter table person drop column bot_account;
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
||||||
alter table local_user drop column show_bot_accounts;
|
alter table local_user drop column show_bot_accounts;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
-- Add the bot_account column to the person table
|
-- Add the bot_account column to the person table
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
alter table person add column bot_account boolean not null default false;
|
alter table person add column bot_account boolean not null default false;
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
||||||
-- Add the show_bot_accounts to the local user table as a setting
|
-- Add the show_bot_accounts to the local user table as a setting
|
||||||
alter table local_user add column show_bot_accounts boolean not null default true;
|
alter table local_user add column show_bot_accounts boolean not null default true;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
alter table person rename display_name to preferred_username;
|
alter table person rename display_name to preferred_username;
|
||||||
|
|
||||||
-- Regenerate the person_alias views
|
-- Regenerate the person_alias views
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
alter table person rename preferred_username to display_name;
|
alter table person rename preferred_username to display_name;
|
||||||
|
|
||||||
-- Regenerate the person_alias views
|
-- Regenerate the person_alias views
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
DROP VIEW person_alias_1;
|
DROP VIEW aliases::person_1;
|
||||||
DROP VIEW person_alias_2;
|
DROP VIEW aliases::person_2;
|
||||||
|
|
||||||
ALTER TABLE community ALTER COLUMN name TYPE varchar(20);
|
ALTER TABLE community ALTER COLUMN name TYPE varchar(20);
|
||||||
ALTER TABLE community ALTER COLUMN title TYPE varchar(100);
|
ALTER TABLE community ALTER COLUMN title TYPE varchar(100);
|
||||||
ALTER TABLE person ALTER COLUMN name TYPE varchar(20);
|
ALTER TABLE person ALTER COLUMN name TYPE varchar(20);
|
||||||
ALTER TABLE person ALTER COLUMN display_name TYPE varchar(20);
|
ALTER TABLE person ALTER COLUMN display_name TYPE varchar(20);
|
||||||
|
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
DROP VIEW person_alias_1;
|
DROP VIEW aliases::person_1;
|
||||||
DROP VIEW person_alias_2;
|
DROP VIEW aliases::person_2;
|
||||||
|
|
||||||
ALTER TABLE community ALTER COLUMN name TYPE varchar(255);
|
ALTER TABLE community ALTER COLUMN name TYPE varchar(255);
|
||||||
ALTER TABLE community ALTER COLUMN title TYPE varchar(255);
|
ALTER TABLE community ALTER COLUMN title TYPE varchar(255);
|
||||||
ALTER TABLE person ALTER COLUMN name TYPE varchar(255);
|
ALTER TABLE person ALTER COLUMN name TYPE varchar(255);
|
||||||
ALTER TABLE person ALTER COLUMN display_name TYPE varchar(255);
|
ALTER TABLE person ALTER COLUMN display_name TYPE varchar(255);
|
||||||
|
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
|
|
||||||
alter table person drop column ban_expires;
|
alter table person drop column ban_expires;
|
||||||
alter table community_person_ban drop column expires;
|
alter table community_person_ban drop column expires;
|
||||||
|
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
alter table person add column ban_expires timestamp;
|
alter table person add column ban_expires timestamp;
|
||||||
alter table community_person_ban add column expires timestamp;
|
alter table community_person_ban add column expires timestamp;
|
||||||
|
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
create view person_alias_1 as select * from person;
|
create view aliases::person_1 as select * from person;
|
||||||
create view person_alias_2 as select * from person;
|
create view aliases::person_2 as select * from person;
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
-- Drop the alias views
|
-- Drop the alias views
|
||||||
drop view person_alias_1, person_alias_2;
|
drop view aliases::person_1, aliases::person_2;
|
||||||
|
|
Loading…
Reference in a new issue