mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 11:21:32 +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]
|
||||
#[allow(clippy::wildcard_imports)]
|
||||
pub mod schema;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod aliases;
|
||||
pub mod source;
|
||||
#[cfg(feature = "full")]
|
||||
pub mod traits;
|
||||
|
|
|
@ -14,6 +14,7 @@ use diesel_async::RunQueryDsl;
|
|||
use futures::future::{BoxFuture, FutureExt};
|
||||
use lemmy_db_schema::{
|
||||
aggregates::structs::CommentAggregates,
|
||||
aliases,
|
||||
newtypes::{CommentReportId, CommunityId, PersonId},
|
||||
schema::{
|
||||
comment,
|
||||
|
@ -37,9 +38,6 @@ use lemmy_db_schema::{
|
|||
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>() -> (
|
||||
impl Fn(
|
||||
DbConn<'a>,
|
||||
|
@ -60,7 +58,7 @@ fn queries<'a>() -> (
|
|||
.inner_join(post::table.on(comment::post_id.eq(post::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_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(
|
||||
comment_aggregates::table.on(comment_report::comment_id.eq(comment_aggregates::comment_id)),
|
||||
)
|
||||
|
@ -86,8 +84,8 @@ fn queries<'a>() -> (
|
|||
),
|
||||
)
|
||||
.left_join(
|
||||
person_alias_2
|
||||
.on(comment_report::resolver_id.eq(person_alias_2.field(person::id).nullable())),
|
||||
aliases::person_2
|
||||
.on(comment_report::resolver_id.eq(aliases::person_2.field(person::id).nullable())),
|
||||
)
|
||||
.select((
|
||||
comment_report::all_columns,
|
||||
|
@ -95,11 +93,11 @@ fn queries<'a>() -> (
|
|||
post::all_columns,
|
||||
community::all_columns,
|
||||
person::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
comment_aggregates::all_columns,
|
||||
community_person_ban::all_columns.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| {
|
||||
|
@ -130,7 +128,6 @@ fn queries<'a>() -> (
|
|||
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
|
||||
|
||||
query = query
|
||||
|
||||
.order_by(comment_report::published.desc())
|
||||
.limit(limit)
|
||||
.offset(offset);
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aggregates::structs::PostAggregates,
|
||||
aliases,
|
||||
newtypes::{CommunityId, PersonId, PostReportId},
|
||||
schema::{
|
||||
community,
|
||||
|
@ -53,7 +54,6 @@ impl PostReportView {
|
|||
my_person_id: PersonId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
|
||||
|
||||
let (
|
||||
post_report,
|
||||
|
@ -70,7 +70,7 @@ impl PostReportView {
|
|||
.inner_join(post::table)
|
||||
.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_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(
|
||||
community_person_ban::table.on(
|
||||
post::community_id
|
||||
|
@ -87,18 +87,19 @@ impl PostReportView {
|
|||
)
|
||||
.inner_join(post_aggregates::table.on(post_report::post_id.eq(post_aggregates::post_id)))
|
||||
.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((
|
||||
post_report::all_columns,
|
||||
post::all_columns,
|
||||
community::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(),
|
||||
post_like::score.nullable(),
|
||||
post_aggregates::all_columns,
|
||||
person_alias_2.fields(person::all_columns.nullable()),
|
||||
aliases::person_2.fields(person::all_columns.nullable()),
|
||||
))
|
||||
.first::<PostReportViewTuple>(conn)
|
||||
.await?;
|
||||
|
@ -173,13 +174,12 @@ impl PostReportQuery {
|
|||
my_person: &Person,
|
||||
) -> Result<Vec<PostReportView>, Error> {
|
||||
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
|
||||
.inner_join(post::table)
|
||||
.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_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(
|
||||
community_person_ban::table.on(
|
||||
post::community_id
|
||||
|
@ -196,18 +196,19 @@ impl PostReportQuery {
|
|||
)
|
||||
.inner_join(post_aggregates::table.on(post_report::post_id.eq(post_aggregates::post_id)))
|
||||
.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((
|
||||
post_report::all_columns,
|
||||
post::all_columns,
|
||||
community::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(),
|
||||
post_like::score.nullable(),
|
||||
post_aggregates::all_columns,
|
||||
person_alias_2.fields(person::all_columns.nullable()),
|
||||
aliases::person_2.fields(person::all_columns.nullable()),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::structs::PrivateMessageReportView;
|
|||
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PrivateMessageReportId,
|
||||
schema::{person, private_message, private_message_report},
|
||||
source::{
|
||||
|
@ -30,7 +31,6 @@ impl PrivateMessageReportView {
|
|||
report_id: PrivateMessageReportId,
|
||||
) -> Result<Self, Error> {
|
||||
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) =
|
||||
private_message_report::table
|
||||
|
@ -38,20 +38,18 @@ impl PrivateMessageReportView {
|
|||
.inner_join(private_message::table)
|
||||
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
||||
.inner_join(
|
||||
person_alias_1
|
||||
.on(private_message_report::creator_id.eq(person_alias_1.field(person::id))),
|
||||
)
|
||||
.left_join(
|
||||
person_alias_2.on(
|
||||
private_message_report::resolver_id.eq(person_alias_2.field(person::id).nullable()),
|
||||
),
|
||||
aliases::person_1
|
||||
.on(private_message_report::creator_id.eq(aliases::person_1.field(person::id))),
|
||||
)
|
||||
.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,
|
||||
private_message::all_columns,
|
||||
person::all_columns,
|
||||
person_alias_1.fields(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(),
|
||||
))
|
||||
.first::<PrivateMessageReportViewTuple>(conn)
|
||||
.await?;
|
||||
|
@ -90,24 +88,24 @@ pub struct PrivateMessageReportQuery {
|
|||
impl PrivateMessageReportQuery {
|
||||
pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<PrivateMessageReportView>, Error> {
|
||||
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 =
|
||||
private_message_report::table
|
||||
.inner_join(private_message::table)
|
||||
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
||||
.inner_join(
|
||||
person_alias_1.on(private_message_report::creator_id.eq(person_alias_1.field(person::id))),
|
||||
)
|
||||
.left_join(
|
||||
person_alias_2
|
||||
.on(private_message_report::resolver_id.eq(person_alias_2.field(person::id).nullable())),
|
||||
aliases::person_1
|
||||
.on(private_message_report::creator_id.eq(aliases::person_1.field(person::id))),
|
||||
)
|
||||
.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,
|
||||
private_message::all_columns,
|
||||
person::all_columns,
|
||||
person_alias_1.fields(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();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::{PersonId, PrivateMessageId},
|
||||
schema::{person, private_message},
|
||||
source::{person::Person, private_message::PrivateMessage},
|
||||
|
@ -26,19 +27,18 @@ impl PrivateMessageView {
|
|||
private_message_id: PrivateMessageId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
let (private_message, creator, recipient) = private_message::table
|
||||
.find(private_message_id)
|
||||
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
||||
.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())
|
||||
.select((
|
||||
private_message::all_columns,
|
||||
person::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
))
|
||||
.first::<PrivateMessageViewTuple>(conn)
|
||||
.await?;
|
||||
|
@ -81,17 +81,16 @@ impl PrivateMessageQuery {
|
|||
recipient_id: PersonId,
|
||||
) -> Result<Vec<PrivateMessageView>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
let mut query = private_message::table
|
||||
.inner_join(person::table.on(private_message::creator_id.eq(person::id)))
|
||||
.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((
|
||||
private_message::all_columns,
|
||||
person::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
schema::{local_user, person, registration_application},
|
||||
source::{
|
||||
local_user::LocalUser,
|
||||
|
@ -28,7 +29,6 @@ impl RegistrationApplicationView {
|
|||
registration_application_id: i32,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
let (registration_application, creator_local_user, creator, admin) =
|
||||
registration_application::table
|
||||
|
@ -37,16 +37,15 @@ impl RegistrationApplicationView {
|
|||
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)))
|
||||
.left_join(
|
||||
person_alias_1
|
||||
.on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())),
|
||||
)
|
||||
.left_join(aliases::person_1.on(
|
||||
registration_application::admin_id.eq(aliases::person_1.field(person::id).nullable()),
|
||||
))
|
||||
.order_by(registration_application::published.desc())
|
||||
.select((
|
||||
registration_application::all_columns,
|
||||
local_user::all_columns,
|
||||
person::all_columns,
|
||||
person_alias_1.fields(person::all_columns).nullable(),
|
||||
aliases::person_1.fields(person::all_columns).nullable(),
|
||||
))
|
||||
.first::<RegistrationApplicationViewTuple>(conn)
|
||||
.await?;
|
||||
|
@ -65,14 +64,14 @@ impl RegistrationApplicationView {
|
|||
verified_email_only: bool,
|
||||
) -> Result<i64, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
let mut query = registration_application::table
|
||||
.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)))
|
||||
.left_join(
|
||||
person_alias_1
|
||||
.on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())),
|
||||
aliases::person_1.on(
|
||||
registration_application::admin_id.eq(aliases::person_1.field(person::id).nullable()),
|
||||
),
|
||||
)
|
||||
.filter(registration_application::admin_id.is_null())
|
||||
.into_boxed();
|
||||
|
@ -102,21 +101,21 @@ impl RegistrationApplicationQuery {
|
|||
pool: &mut DbPool<'_>,
|
||||
) -> Result<Vec<RegistrationApplicationView>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
let mut query = registration_application::table
|
||||
.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)))
|
||||
.left_join(
|
||||
person_alias_1
|
||||
.on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())),
|
||||
aliases::person_1.on(
|
||||
registration_application::admin_id.eq(aliases::person_1.field(person::id).nullable()),
|
||||
),
|
||||
)
|
||||
.order_by(registration_application::published.desc())
|
||||
.select((
|
||||
registration_application::all_columns,
|
||||
local_user::all_columns,
|
||||
person::all_columns,
|
||||
person_alias_1.fields(person::all_columns).nullable(),
|
||||
aliases::person_1.fields(person::all_columns).nullable(),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aggregates::structs::CommentAggregates,
|
||||
aliases,
|
||||
newtypes::{CommentReplyId, PersonId},
|
||||
schema::{
|
||||
comment,
|
||||
|
@ -59,7 +60,6 @@ impl CommentReplyView {
|
|||
my_person_id: Option<PersonId>,
|
||||
) -> Result<Self, Error> {
|
||||
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
|
||||
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(post::table.on(comment::post_id.eq(post::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)))
|
||||
.left_join(
|
||||
community_person_ban::table.on(
|
||||
|
@ -126,7 +126,7 @@ impl CommentReplyView {
|
|||
person::all_columns,
|
||||
post::all_columns,
|
||||
community::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
comment_aggregates::all_columns,
|
||||
community_person_ban::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> {
|
||||
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
|
||||
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(post::table.on(comment::post_id.eq(post::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)))
|
||||
.left_join(
|
||||
community_person_ban::table.on(
|
||||
|
@ -242,7 +240,7 @@ impl CommentReplyQuery {
|
|||
person::all_columns,
|
||||
post::all_columns,
|
||||
community::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
comment_aggregates::all_columns,
|
||||
community_person_ban::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_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{person, person_block},
|
||||
source::person::Person,
|
||||
|
@ -14,7 +15,7 @@ type PersonBlockViewTuple = (Person, Person);
|
|||
impl PersonBlockView {
|
||||
pub async fn for_person(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
||||
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
|
||||
.inner_join(person::table.on(person_block::person_id.eq(person::id)))
|
||||
|
|
|
@ -11,6 +11,7 @@ use diesel::{
|
|||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aggregates::structs::CommentAggregates,
|
||||
aliases,
|
||||
newtypes::{PersonId, PersonMentionId},
|
||||
schema::{
|
||||
comment,
|
||||
|
@ -60,7 +61,6 @@ impl PersonMentionView {
|
|||
my_person_id: Option<PersonId>,
|
||||
) -> Result<Self, Error> {
|
||||
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
|
||||
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(post::table.on(comment::post_id.eq(post::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)))
|
||||
.left_join(
|
||||
community_person_ban::table.on(
|
||||
|
@ -127,7 +127,7 @@ impl PersonMentionView {
|
|||
person::all_columns,
|
||||
post::all_columns,
|
||||
community::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
comment_aggregates::all_columns,
|
||||
community_person_ban::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> {
|
||||
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
|
||||
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(post::table.on(comment::post_id.eq(post::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)))
|
||||
.left_join(
|
||||
community_person_ban::table.on(
|
||||
|
@ -247,7 +245,7 @@ impl PersonMentionQuery {
|
|||
person::all_columns,
|
||||
post::all_columns,
|
||||
community::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
comment_aggregates::all_columns,
|
||||
community_person_ban::all_columns.nullable(),
|
||||
community_follower::all_columns.nullable(),
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_add_community, person},
|
||||
source::{community::Community, moderator::ModAddCommunity, person::Person},
|
||||
|
@ -22,7 +23,7 @@ type ModAddCommunityViewTuple = (ModAddCommunity, Option<Person>, Community, Per
|
|||
impl ModAddCommunityView {
|
||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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))
|
||||
.inner_join(community::table)
|
||||
.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((
|
||||
mod_add_community::all_columns,
|
||||
person::all_columns.nullable(),
|
||||
community::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
|
@ -53,7 +55,7 @@ impl ModAddCommunityView {
|
|||
};
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{mod_add, person},
|
||||
source::{moderator::ModAdd, person::Person},
|
||||
|
@ -22,7 +23,7 @@ type ModAddViewTuple = (ModAdd, Option<Person>, Person);
|
|||
impl ModAddView {
|
||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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)));
|
||||
let mut query = mod_add::table
|
||||
.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((
|
||||
mod_add::all_columns,
|
||||
person::all_columns.nullable(),
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
|
@ -45,7 +48,7 @@ impl ModAddView {
|
|||
};
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_ban_from_community, 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> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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))
|
||||
.inner_join(community::table)
|
||||
.inner_join(
|
||||
person_alias_1
|
||||
.on(mod_ban_from_community::other_person_id.eq(person_alias_1.field(person::id))),
|
||||
aliases::person_1
|
||||
.on(mod_ban_from_community::other_person_id.eq(aliases::person_1.field(person::id))),
|
||||
)
|
||||
.select((
|
||||
mod_ban_from_community::all_columns,
|
||||
person::all_columns.nullable(),
|
||||
community::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{mod_ban, person},
|
||||
source::{moderator::ModBan, person::Person},
|
||||
|
@ -22,7 +23,7 @@ type ModBanViewTuple = (ModBan, Option<Person>, Person);
|
|||
impl ModBanView {
|
||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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)));
|
||||
let mut query = mod_ban::table
|
||||
.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((
|
||||
mod_ban::all_columns,
|
||||
person::all_columns.nullable(),
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
|
@ -45,7 +48,7 @@ impl ModBanView {
|
|||
};
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_feature_post, person, post},
|
||||
source::{community::Community, moderator::ModFeaturePost, person::Person, post::Post},
|
||||
|
@ -22,7 +23,7 @@ type ModFeaturePostViewTuple = (ModFeaturePost, Option<Person>, Post, Community)
|
|||
impl ModFeaturePostView {
|
||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.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)))
|
||||
.select((
|
||||
mod_feature_post::all_columns,
|
||||
|
@ -52,7 +53,7 @@ impl ModFeaturePostView {
|
|||
};
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_lock_post, person, 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> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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))
|
||||
.inner_join(post::table)
|
||||
.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((
|
||||
mod_lock_post::all_columns,
|
||||
person::all_columns.nullable(),
|
||||
|
@ -53,7 +53,7 @@ impl ModLockPostView {
|
|||
};
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{comment, community, mod_remove_comment, person, post},
|
||||
source::{
|
||||
|
@ -35,7 +36,6 @@ type ModRemoveCommentViewTuple = (
|
|||
impl ModRemoveCommentView {
|
||||
pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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
|
||||
.left_join(person::table.on(admin_names_join))
|
||||
.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(community::table.on(post::community_id.eq(community::id)))
|
||||
.select((
|
||||
mod_remove_comment::all_columns,
|
||||
person::all_columns.nullable(),
|
||||
comment::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
post::all_columns,
|
||||
community::all_columns,
|
||||
))
|
||||
|
@ -68,7 +68,7 @@ impl ModRemoveCommentView {
|
|||
};
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_remove_post, person, 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> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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))
|
||||
.inner_join(post::table)
|
||||
.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((
|
||||
mod_remove_post::all_columns,
|
||||
person::all_columns.nullable(),
|
||||
|
@ -53,7 +53,7 @@ impl ModRemovePostView {
|
|||
};
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -10,6 +10,7 @@ use diesel::{
|
|||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_db_schema::{
|
||||
aliases,
|
||||
newtypes::PersonId,
|
||||
schema::{community, mod_transfer_community, 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> {
|
||||
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 show_mod_names = !params.hide_modlog_names;
|
||||
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))
|
||||
.inner_join(community::table)
|
||||
.inner_join(
|
||||
person_alias_1
|
||||
.on(mod_transfer_community::other_person_id.eq(person_alias_1.field(person::id))),
|
||||
aliases::person_1
|
||||
.on(mod_transfer_community::other_person_id.eq(aliases::person_1.field(person::id))),
|
||||
)
|
||||
.select((
|
||||
mod_transfer_community::all_columns,
|
||||
person::all_columns.nullable(),
|
||||
community::all_columns,
|
||||
person_alias_1.fields(person::all_columns),
|
||||
aliases::person_1.fields(person::all_columns),
|
||||
))
|
||||
.into_boxed();
|
||||
|
||||
|
@ -55,7 +55,7 @@ impl ModTransferCommunityView {
|
|||
};
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -135,7 +135,7 @@ drop function
|
|||
|
||||
-- user_ table
|
||||
-- Drop views
|
||||
drop view person_alias_1, person_alias_2;
|
||||
drop view aliases::person_1, aliases::person_2;
|
||||
|
||||
-- Rename indexes
|
||||
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;
|
||||
|
||||
-- Create views
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
create view aliases::person_1 as select * from person;
|
||||
create view aliases::person_2 as select * from person;
|
||||
|
||||
-- Redo user aggregates into person_aggregates
|
||||
alter table user_aggregates rename to person_aggregates;
|
||||
|
|
|
@ -8,10 +8,10 @@ set
|
|||
from person p
|
||||
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 admin;
|
||||
|
||||
-- Regenerate the person_alias views
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
create view aliases::person_1 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;
|
||||
|
||||
-- Regenerate the person_alias views
|
||||
drop view person_alias_1, person_alias_2;
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
drop view aliases::person_1, aliases::person_2;
|
||||
create view aliases::person_1 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;
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
create view aliases::person_1 as select * from person;
|
||||
create view aliases::person_2 as select * from person;
|
||||
|
||||
alter table local_user drop column show_bot_accounts;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
-- 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;
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
create view aliases::person_1 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
|
||||
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;
|
||||
|
||||
-- Regenerate the person_alias views
|
||||
drop view person_alias_1, person_alias_2;
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
drop view aliases::person_1, aliases::person_2;
|
||||
create view aliases::person_1 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;
|
||||
|
||||
-- Regenerate the person_alias views
|
||||
drop view person_alias_1, person_alias_2;
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
drop view aliases::person_1, aliases::person_2;
|
||||
create view aliases::person_1 as select * from person;
|
||||
create view aliases::person_2 as select * from person;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
DROP VIEW person_alias_1;
|
||||
DROP VIEW person_alias_2;
|
||||
DROP VIEW aliases::person_1;
|
||||
DROP VIEW aliases::person_2;
|
||||
|
||||
ALTER TABLE community ALTER COLUMN name TYPE varchar(20);
|
||||
ALTER TABLE community ALTER COLUMN title TYPE varchar(100);
|
||||
ALTER TABLE person ALTER COLUMN 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 person_alias_2 as select * from person;
|
||||
create view aliases::person_1 as select * from person;
|
||||
create view aliases::person_2 as select * from person;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
DROP VIEW person_alias_1;
|
||||
DROP VIEW person_alias_2;
|
||||
DROP VIEW aliases::person_1;
|
||||
DROP VIEW aliases::person_2;
|
||||
|
||||
ALTER TABLE community ALTER COLUMN name 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 display_name TYPE varchar(255);
|
||||
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
create view aliases::person_1 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 community_person_ban drop column expires;
|
||||
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
create view aliases::person_1 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 community_person_ban add column expires timestamp;
|
||||
|
||||
drop view person_alias_1, person_alias_2;
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
||||
drop view aliases::person_1, aliases::person_2;
|
||||
create view aliases::person_1 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 person_alias_2 as select * from person;
|
||||
create view aliases::person_1 as select * from person;
|
||||
create view aliases::person_2 as select * from person;
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
-- 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