From 69afed05c1807c3fef8d5b5872546fa22e60b4d0 Mon Sep 17 00:00:00 2001 From: dull b Date: Wed, 19 Jul 2023 18:11:21 +0000 Subject: [PATCH] Move aliases to db_schema --- crates/db_schema/src/aliases.rs | 5 ++ crates/db_schema/src/lib.rs | 2 + crates/db_views/src/comment_report_view.rs | 15 ++--- crates/db_views/src/post_report_view.rs | 21 +++---- .../src/private_message_report_view.rs | 56 +++++++++---------- crates/db_views/src/private_message_view.rs | 11 ++-- .../src/registration_application_view.rs | 25 ++++----- .../db_views_actor/src/comment_reply_view.rs | 12 ++-- .../db_views_actor/src/person_block_view.rs | 3 +- .../db_views_actor/src/person_mention_view.rs | 12 ++-- .../src/mod_add_community_view.rs | 10 ++-- crates/db_views_moderator/src/mod_add_view.rs | 11 ++-- .../src/mod_ban_from_community_view.rs | 8 +-- crates/db_views_moderator/src/mod_ban_view.rs | 11 ++-- .../src/mod_feature_post_view.rs | 7 ++- .../src/mod_lock_post_view.rs | 6 +- .../src/mod_remove_comment_view.rs | 8 +-- .../src/mod_remove_post_view.rs | 6 +- .../src/mod_transfer_community_view.rs | 10 ++-- .../down.sql | 2 +- .../up.sql | 4 +- .../down.sql | 6 +- .../up.sql | 6 +- .../down.sql | 6 +- .../2021-03-31-105915_add_bot_account/up.sql | 6 +- .../down.sql | 6 +- .../up.sql | 6 +- .../down.sql | 8 +-- .../up.sql | 8 +-- .../down.sql | 6 +- .../up.sql | 6 +- .../down.sql | 4 +- .../up.sql | 2 +- 33 files changed, 161 insertions(+), 154 deletions(-) create mode 100644 crates/db_schema/src/aliases.rs diff --git a/crates/db_schema/src/aliases.rs b/crates/db_schema/src/aliases.rs new file mode 100644 index 000000000..0f251a154 --- /dev/null +++ b/crates/db_schema/src/aliases.rs @@ -0,0 +1,5 @@ +use crate::schema::person; + +diesel::alias! { + const PERSON_1 = person as person_1: Person1, person as person_2: Person2 +}; diff --git a/crates/db_schema/src/lib.rs b/crates/db_schema/src/lib.rs index acb069ca7..badb083d8 100644 --- a/crates/db_schema/src/lib.rs +++ b/crates/db_schema/src/lib.rs @@ -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; diff --git a/crates/db_views/src/comment_report_view.rs b/crates/db_views/src/comment_report_view.rs index 30e4f517a..67ada36e1 100644 --- a/crates/db_views/src/comment_report_view.rs +++ b/crates/db_views/src/comment_report_view.rs @@ -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); diff --git a/crates/db_views/src/post_report_view.rs b/crates/db_views/src/post_report_view.rs index 50b35b1c2..5ded63fcf 100644 --- a/crates/db_views/src/post_report_view.rs +++ b/crates/db_views/src/post_report_view.rs @@ -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 { 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::(conn) .await?; @@ -173,13 +174,12 @@ impl PostReportQuery { my_person: &Person, ) -> Result, 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(); diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/private_message_report_view.rs index 7ceca271a..70ed568e5 100644 --- a/crates/db_views/src/private_message_report_view.rs +++ b/crates/db_views/src/private_message_report_view.rs @@ -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 { 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::(conn) .await?; @@ -90,26 +88,26 @@ pub struct PrivateMessageReportQuery { impl PrivateMessageReportQuery { pub async fn list(self, pool: &mut DbPool<'_>) -> Result, 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 - .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())), - ) - .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(), - )) - .into_boxed(); + 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( + 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, + aliases::person_1.fields(person::all_columns), + aliases::person_2.fields(person::all_columns).nullable(), + )) + .into_boxed(); if self.unresolved_only.unwrap_or(false) { query = query.filter(private_message_report::resolved.eq(false)); diff --git a/crates/db_views/src/private_message_view.rs b/crates/db_views/src/private_message_view.rs index 863db8125..ee742a949 100644 --- a/crates/db_views/src/private_message_view.rs +++ b/crates/db_views/src/private_message_view.rs @@ -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 { 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::(conn) .await?; @@ -81,17 +81,16 @@ impl PrivateMessageQuery { recipient_id: PersonId, ) -> Result, 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(); diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index 106e41e43..02793266f 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -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 { 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::(conn) .await?; @@ -65,14 +64,14 @@ impl RegistrationApplicationView { verified_email_only: bool, ) -> Result { 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, 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(); diff --git a/crates/db_views_actor/src/comment_reply_view.rs b/crates/db_views_actor/src/comment_reply_view.rs index 4d7a8eac4..76bbbda4b 100644 --- a/crates/db_views_actor/src/comment_reply_view.rs +++ b/crates/db_views_actor/src/comment_reply_view.rs @@ -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, ) -> Result { 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, 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(), diff --git a/crates/db_views_actor/src/person_block_view.rs b/crates/db_views_actor/src/person_block_view.rs index b317740da..1e17d4a33 100644 --- a/crates/db_views_actor/src/person_block_view.rs +++ b/crates/db_views_actor/src/person_block_view.rs @@ -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, 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))) diff --git a/crates/db_views_actor/src/person_mention_view.rs b/crates/db_views_actor/src/person_mention_view.rs index 3e142254a..0b1c5f5e5 100644 --- a/crates/db_views_actor/src/person_mention_view.rs +++ b/crates/db_views_actor/src/person_mention_view.rs @@ -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, ) -> Result { 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, 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(), diff --git a/crates/db_views_moderator/src/mod_add_community_view.rs b/crates/db_views_moderator/src/mod_add_community_view.rs index c1166b6dd..1de610c33 100644 --- a/crates/db_views_moderator/src/mod_add_community_view.rs +++ b/crates/db_views_moderator/src/mod_add_community_view.rs @@ -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, Community, Per impl ModAddCommunityView { pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result, 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::(); @@ -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)?; diff --git a/crates/db_views_moderator/src/mod_add_view.rs b/crates/db_views_moderator/src/mod_add_view.rs index 7094db123..91b81c0aa 100644 --- a/crates/db_views_moderator/src/mod_add_view.rs +++ b/crates/db_views_moderator/src/mod_add_view.rs @@ -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); impl ModAddView { pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result, 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::(); @@ -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)?; diff --git a/crates/db_views_moderator/src/mod_ban_from_community_view.rs b/crates/db_views_moderator/src/mod_ban_from_community_view.rs index ceed974bd..1b20b78b7 100644 --- a/crates/db_views_moderator/src/mod_ban_from_community_view.rs +++ b/crates/db_views_moderator/src/mod_ban_from_community_view.rs @@ -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, 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::(); @@ -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(); diff --git a/crates/db_views_moderator/src/mod_ban_view.rs b/crates/db_views_moderator/src/mod_ban_view.rs index 835804e67..52377b701 100644 --- a/crates/db_views_moderator/src/mod_ban_view.rs +++ b/crates/db_views_moderator/src/mod_ban_view.rs @@ -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); impl ModBanView { pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result, 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::(); @@ -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)?; diff --git a/crates/db_views_moderator/src/mod_feature_post_view.rs b/crates/db_views_moderator/src/mod_feature_post_view.rs index 16a645f2c..258e9f8ae 100644 --- a/crates/db_views_moderator/src/mod_feature_post_view.rs +++ b/crates/db_views_moderator/src/mod_feature_post_view.rs @@ -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, Post, Community) impl ModFeaturePostView { pub async fn list(pool: &mut DbPool<'_>, params: ModlogListParams) -> Result, 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::(); @@ -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)?; diff --git a/crates/db_views_moderator/src/mod_lock_post_view.rs b/crates/db_views_moderator/src/mod_lock_post_view.rs index b970a3f6c..35ca0e30e 100644 --- a/crates/db_views_moderator/src/mod_lock_post_view.rs +++ b/crates/db_views_moderator/src/mod_lock_post_view.rs @@ -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, 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::(); @@ -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)?; diff --git a/crates/db_views_moderator/src/mod_remove_comment_view.rs b/crates/db_views_moderator/src/mod_remove_comment_view.rs index 946e0eb37..f1e3146d5 100644 --- a/crates/db_views_moderator/src/mod_remove_comment_view.rs +++ b/crates/db_views_moderator/src/mod_remove_comment_view.rs @@ -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, 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::(); @@ -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)?; diff --git a/crates/db_views_moderator/src/mod_remove_post_view.rs b/crates/db_views_moderator/src/mod_remove_post_view.rs index 74cd3c489..cfcecfbd3 100644 --- a/crates/db_views_moderator/src/mod_remove_post_view.rs +++ b/crates/db_views_moderator/src/mod_remove_post_view.rs @@ -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, 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::(); @@ -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)?; diff --git a/crates/db_views_moderator/src/mod_transfer_community_view.rs b/crates/db_views_moderator/src/mod_transfer_community_view.rs index d84ed87da..aefb58d71 100644 --- a/crates/db_views_moderator/src/mod_transfer_community_view.rs +++ b/crates/db_views_moderator/src/mod_transfer_community_view.rs @@ -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, 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::(); @@ -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)?; diff --git a/migrations/2021-03-09-171136_split_user_table_2/down.sql b/migrations/2021-03-09-171136_split_user_table_2/down.sql index e1d55a205..af5f46d21 100644 --- a/migrations/2021-03-09-171136_split_user_table_2/down.sql +++ b/migrations/2021-03-09-171136_split_user_table_2/down.sql @@ -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; diff --git a/migrations/2021-03-09-171136_split_user_table_2/up.sql b/migrations/2021-03-09-171136_split_user_table_2/up.sql index db3547e5f..a75a50385 100644 --- a/migrations/2021-03-09-171136_split_user_table_2/up.sql +++ b/migrations/2021-03-09-171136_split_user_table_2/up.sql @@ -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; diff --git a/migrations/2021-03-20-185321_move_matrix_id_to_person/down.sql b/migrations/2021-03-20-185321_move_matrix_id_to_person/down.sql index 990d8fe97..3925ba4b2 100644 --- a/migrations/2021-03-20-185321_move_matrix_id_to_person/down.sql +++ b/migrations/2021-03-20-185321_move_matrix_id_to_person/down.sql @@ -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; diff --git a/migrations/2021-03-20-185321_move_matrix_id_to_person/up.sql b/migrations/2021-03-20-185321_move_matrix_id_to_person/up.sql index d9ba3dd9c..9c7bff371 100644 --- a/migrations/2021-03-20-185321_move_matrix_id_to_person/up.sql +++ b/migrations/2021-03-20-185321_move_matrix_id_to_person/up.sql @@ -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; diff --git a/migrations/2021-03-31-105915_add_bot_account/down.sql b/migrations/2021-03-31-105915_add_bot_account/down.sql index 4f407ce86..ecd6c4fb8 100644 --- a/migrations/2021-03-31-105915_add_bot_account/down.sql +++ b/migrations/2021-03-31-105915_add_bot_account/down.sql @@ -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; diff --git a/migrations/2021-03-31-105915_add_bot_account/up.sql b/migrations/2021-03-31-105915_add_bot_account/up.sql index a1e207a1d..745819470 100644 --- a/migrations/2021-03-31-105915_add_bot_account/up.sql +++ b/migrations/2021-03-31-105915_add_bot_account/up.sql @@ -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; diff --git a/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql b/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql index 844c02d38..4156f9e05 100644 --- a/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql +++ b/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/down.sql @@ -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; diff --git a/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql b/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql index f4b9729c1..336096181 100644 --- a/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql +++ b/migrations/2021-04-01-173552_rename_preferred_username_to_display_name/up.sql @@ -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; diff --git a/migrations/2021-07-20-102033_actor_name_length/down.sql b/migrations/2021-07-20-102033_actor_name_length/down.sql index 76cec4c91..25890b3a1 100644 --- a/migrations/2021-07-20-102033_actor_name_length/down.sql +++ b/migrations/2021-07-20-102033_actor_name_length/down.sql @@ -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; diff --git a/migrations/2021-07-20-102033_actor_name_length/up.sql b/migrations/2021-07-20-102033_actor_name_length/up.sql index 2e7bc9dfb..1f73e5946 100644 --- a/migrations/2021-07-20-102033_actor_name_length/up.sql +++ b/migrations/2021-07-20-102033_actor_name_length/up.sql @@ -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; diff --git a/migrations/2021-12-14-181537_add_temporary_bans/down.sql b/migrations/2021-12-14-181537_add_temporary_bans/down.sql index 83a3715ec..efaf4f481 100644 --- a/migrations/2021-12-14-181537_add_temporary_bans/down.sql +++ b/migrations/2021-12-14-181537_add_temporary_bans/down.sql @@ -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; diff --git a/migrations/2021-12-14-181537_add_temporary_bans/up.sql b/migrations/2021-12-14-181537_add_temporary_bans/up.sql index 7e6338361..a86d736fd 100644 --- a/migrations/2021-12-14-181537_add_temporary_bans/up.sql +++ b/migrations/2021-12-14-181537_add_temporary_bans/up.sql @@ -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; diff --git a/migrations/2022-09-24-161829_remove_table_aliases/down.sql b/migrations/2022-09-24-161829_remove_table_aliases/down.sql index 39b439a0a..393acca30 100644 --- a/migrations/2022-09-24-161829_remove_table_aliases/down.sql +++ b/migrations/2022-09-24-161829_remove_table_aliases/down.sql @@ -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; diff --git a/migrations/2022-09-24-161829_remove_table_aliases/up.sql b/migrations/2022-09-24-161829_remove_table_aliases/up.sql index 36eabecab..d47e59261 100644 --- a/migrations/2022-09-24-161829_remove_table_aliases/up.sql +++ b/migrations/2022-09-24-161829_remove_table_aliases/up.sql @@ -1,2 +1,2 @@ -- Drop the alias views -drop view person_alias_1, person_alias_2; +drop view aliases::person_1, aliases::person_2;