mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
Reviewed-on: https://yerbamate.ml/LemmyNet/lemmy/pulls/176
This commit is contained in:
commit
7c87da012e
32 changed files with 45 additions and 205 deletions
|
@ -170,7 +170,6 @@ impl Perform for CreateCommunity {
|
|||
description: data.description.to_owned(),
|
||||
icon,
|
||||
banner,
|
||||
category_id: data.category_id,
|
||||
creator_id: user.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
@ -273,7 +272,6 @@ impl Perform for EditCommunity {
|
|||
description: data.description.to_owned(),
|
||||
icon,
|
||||
banner,
|
||||
category_id: data.category_id.to_owned(),
|
||||
creator_id: read_community.creator_id,
|
||||
removed: Some(read_community.removed),
|
||||
deleted: Some(read_community.deleted),
|
||||
|
|
|
@ -298,9 +298,6 @@ pub async fn match_websocket_operation(
|
|||
UserOperation::TransferSite => {
|
||||
do_websocket_operation::<TransferSite>(context, id, op, data).await
|
||||
}
|
||||
UserOperation::ListCategories => {
|
||||
do_websocket_operation::<ListCategories>(context, id, op, data).await
|
||||
}
|
||||
|
||||
// Community ops
|
||||
UserOperation::GetCommunity => {
|
||||
|
|
|
@ -22,11 +22,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
|||
.route("/config", web::get().to(route_get::<GetSiteConfig>))
|
||||
.route("/config", web::put().to(route_post::<SaveSiteConfig>)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/categories")
|
||||
.wrap(rate_limit.message())
|
||||
.route(web::get().to(route_get::<ListCategories>)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/modlog")
|
||||
.wrap(rate_limit.message())
|
||||
|
|
|
@ -10,17 +10,10 @@ use crate::{
|
|||
use actix_web::web::Data;
|
||||
use anyhow::Context;
|
||||
use lemmy_apub::fetcher::search::search_by_apub_id;
|
||||
use lemmy_db_queries::{
|
||||
diesel_option_overwrite,
|
||||
source::{category::Category_, site::Site_},
|
||||
Crud,
|
||||
SearchType,
|
||||
SortType,
|
||||
};
|
||||
use lemmy_db_queries::{diesel_option_overwrite, source::site::Site_, Crud, SearchType, SortType};
|
||||
use lemmy_db_schema::{
|
||||
naive_now,
|
||||
source::{
|
||||
category::Category,
|
||||
moderator::*,
|
||||
site::{Site, *},
|
||||
},
|
||||
|
@ -63,24 +56,6 @@ use lemmy_websocket::{
|
|||
use log::{debug, info};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for ListCategories {
|
||||
type Response = ListCategoriesResponse;
|
||||
|
||||
async fn perform(
|
||||
&self,
|
||||
context: &Data<LemmyContext>,
|
||||
_websocket_id: Option<ConnectionId>,
|
||||
) -> Result<ListCategoriesResponse, LemmyError> {
|
||||
let _data: &ListCategories = &self;
|
||||
|
||||
let categories = blocking(context.pool(), move |conn| Category::list_all(conn)).await??;
|
||||
|
||||
// Return the jwt
|
||||
Ok(ListCategoriesResponse { categories })
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for GetModlog {
|
||||
type Response = GetModlogResponse;
|
||||
|
|
|
@ -251,7 +251,6 @@ impl Perform for Register {
|
|||
name: default_community_name.to_string(),
|
||||
title: "The Default Community".to_string(),
|
||||
description: Some("The Default Community".to_string()),
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
creator_id: inserted_user.id,
|
||||
removed: None,
|
||||
|
|
|
@ -1,41 +1,19 @@
|
|||
use activitystreams::unparsed::UnparsedMutExt;
|
||||
use activitystreams_ext::UnparsedExtension;
|
||||
use diesel::PgConnection;
|
||||
use lemmy_db_queries::Crud;
|
||||
use lemmy_db_schema::source::category::Category;
|
||||
use lemmy_utils::LemmyError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Activitystreams extension to allow (de)serializing additional Community fields `category` and
|
||||
/// Activitystreams extension to allow (de)serializing additional Community field
|
||||
/// `sensitive` (called 'nsfw' in Lemmy).
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GroupExtension {
|
||||
pub category: Option<GroupCategory>,
|
||||
pub sensitive: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GroupCategory {
|
||||
// Using a string because that's how Peertube does it.
|
||||
pub identifier: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl GroupExtension {
|
||||
pub fn new(
|
||||
conn: &PgConnection,
|
||||
category_id: i32,
|
||||
sensitive: bool,
|
||||
) -> Result<GroupExtension, LemmyError> {
|
||||
let category = Category::read(conn, category_id)?;
|
||||
let group_category = GroupCategory {
|
||||
identifier: category_id.to_string(),
|
||||
name: category.name,
|
||||
};
|
||||
pub fn new(sensitive: bool) -> Result<GroupExtension, LemmyError> {
|
||||
Ok(GroupExtension {
|
||||
category: Some(group_category),
|
||||
sensitive: Some(sensitive),
|
||||
})
|
||||
}
|
||||
|
@ -49,13 +27,11 @@ where
|
|||
|
||||
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
|
||||
Ok(GroupExtension {
|
||||
category: unparsed_mut.remove("category")?,
|
||||
sensitive: unparsed_mut.remove("sensitive")?,
|
||||
})
|
||||
}
|
||||
|
||||
fn try_into_unparsed(self, unparsed_mut: &mut U) -> Result<(), Self::Error> {
|
||||
unparsed_mut.insert("category", self.category)?;
|
||||
unparsed_mut.insert("sensitive", self.sensitive)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -93,16 +93,9 @@ impl ToApub for Community {
|
|||
..Default::default()
|
||||
});
|
||||
|
||||
let nsfw = self.nsfw;
|
||||
let category_id = self.category_id;
|
||||
let group_extension = blocking(pool, move |conn| {
|
||||
GroupExtension::new(conn, category_id, nsfw)
|
||||
})
|
||||
.await??;
|
||||
|
||||
Ok(Ext2::new(
|
||||
ap_actor,
|
||||
group_extension,
|
||||
GroupExtension::new(self.nsfw)?,
|
||||
self.get_public_key_ext()?,
|
||||
))
|
||||
}
|
||||
|
@ -207,13 +200,6 @@ impl FromApubToForm<GroupExt> for CommunityForm {
|
|||
name,
|
||||
title,
|
||||
description,
|
||||
category_id: group
|
||||
.ext_one
|
||||
.category
|
||||
.clone()
|
||||
.map(|c| c.identifier.parse::<i32>().ok())
|
||||
.flatten()
|
||||
.unwrap_or(1),
|
||||
creator_id: creator.id,
|
||||
removed: None,
|
||||
published: group.inner.published().map(|u| u.to_owned().naive_local()),
|
||||
|
|
|
@ -109,7 +109,6 @@ mod tests {
|
|||
creator_id: inserted_user.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -113,7 +113,6 @@ mod tests {
|
|||
creator_id: inserted_user.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
@ -138,7 +137,6 @@ mod tests {
|
|||
creator_id: inserted_user.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -113,7 +113,6 @@ mod tests {
|
|||
creator_id: inserted_user.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -94,7 +94,6 @@ mod tests {
|
|||
creator_id: inserted_user.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -109,7 +109,6 @@ mod tests {
|
|||
creator_id: inserted_user.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
use crate::Crud;
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use lemmy_db_schema::{schema::category::dsl::*, source::category::*};
|
||||
|
||||
impl Crud<CategoryForm> for Category {
|
||||
fn read(conn: &PgConnection, category_id: i32) -> Result<Self, Error> {
|
||||
category.find(category_id).first::<Self>(conn)
|
||||
}
|
||||
|
||||
fn create(conn: &PgConnection, new_category: &CategoryForm) -> Result<Self, Error> {
|
||||
insert_into(category)
|
||||
.values(new_category)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn update(
|
||||
conn: &PgConnection,
|
||||
category_id: i32,
|
||||
new_category: &CategoryForm,
|
||||
) -> Result<Self, Error> {
|
||||
diesel::update(category.find(category_id))
|
||||
.set(new_category)
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Category_ {
|
||||
fn list_all(conn: &PgConnection) -> Result<Vec<Category>, Error>;
|
||||
}
|
||||
|
||||
impl Category_ for Category {
|
||||
fn list_all(conn: &PgConnection) -> Result<Vec<Category>, Error> {
|
||||
category.load::<Self>(conn)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{establish_unpooled_connection, source::category::Category_};
|
||||
use lemmy_db_schema::source::category::Category;
|
||||
|
||||
#[test]
|
||||
fn test_crud() {
|
||||
let conn = establish_unpooled_connection();
|
||||
|
||||
let categories = Category::list_all(&conn).unwrap();
|
||||
let expected_first_category = Category {
|
||||
id: 1,
|
||||
name: "Discussion".into(),
|
||||
};
|
||||
|
||||
assert_eq!(expected_first_category, categories[0]);
|
||||
}
|
||||
}
|
|
@ -252,7 +252,6 @@ mod tests {
|
|||
name: "test community".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
creator_id: inserted_user.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -24,7 +24,6 @@ mod safe_type {
|
|||
name,
|
||||
title,
|
||||
description,
|
||||
category_id,
|
||||
creator_id,
|
||||
removed,
|
||||
published,
|
||||
|
@ -45,7 +44,6 @@ mod safe_type {
|
|||
name,
|
||||
title,
|
||||
description,
|
||||
category_id,
|
||||
creator_id,
|
||||
removed,
|
||||
published,
|
||||
|
@ -383,7 +381,6 @@ mod tests {
|
|||
creator_id: inserted_user.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
@ -409,7 +406,6 @@ mod tests {
|
|||
name: "TIL".into(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: false,
|
||||
deleted: false,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
pub mod activity;
|
||||
pub mod category;
|
||||
pub mod comment;
|
||||
pub mod comment_report;
|
||||
pub mod community;
|
||||
|
|
|
@ -271,7 +271,6 @@ mod tests {
|
|||
name: "mod_community".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
creator_id: inserted_user.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -271,7 +271,6 @@ mod tests {
|
|||
name: "test community_3".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
creator_id: inserted_user.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -152,7 +152,6 @@ mod tests {
|
|||
name: "test community lake".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
creator_id: inserted_user.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -10,13 +10,6 @@ table! {
|
|||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
category (id) {
|
||||
id -> Int4,
|
||||
name -> Varchar,
|
||||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
comment (id) {
|
||||
id -> Int4,
|
||||
|
@ -85,7 +78,6 @@ table! {
|
|||
name -> Varchar,
|
||||
title -> Varchar,
|
||||
description -> Nullable<Text>,
|
||||
category_id -> Int4,
|
||||
creator_id -> Int4,
|
||||
removed -> Bool,
|
||||
published -> Timestamp,
|
||||
|
@ -546,7 +538,6 @@ joinable!(comment_like -> user_ (user_id));
|
|||
joinable!(comment_report -> comment (comment_id));
|
||||
joinable!(comment_saved -> comment (comment_id));
|
||||
joinable!(comment_saved -> user_ (user_id));
|
||||
joinable!(community -> category (category_id));
|
||||
joinable!(community -> user_ (creator_id));
|
||||
joinable!(community_aggregates -> community (community_id));
|
||||
joinable!(community_follower -> community (community_id));
|
||||
|
@ -587,7 +578,6 @@ joinable!(user_mention -> user_ (recipient_id));
|
|||
|
||||
allow_tables_to_appear_in_same_query!(
|
||||
activity,
|
||||
category,
|
||||
comment,
|
||||
comment_aggregates,
|
||||
comment_like,
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
use crate::schema::category;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Clone)]
|
||||
#[table_name = "category"]
|
||||
pub struct Category {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Insertable, AsChangeset)]
|
||||
#[table_name = "category"]
|
||||
pub struct CategoryForm {
|
||||
pub name: String,
|
||||
}
|
|
@ -11,7 +11,6 @@ pub struct Community {
|
|||
pub name: String,
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub category_id: i32,
|
||||
pub creator_id: i32,
|
||||
pub removed: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
|
@ -38,7 +37,6 @@ pub struct CommunitySafe {
|
|||
pub name: String,
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub category_id: i32,
|
||||
pub creator_id: i32,
|
||||
pub removed: bool,
|
||||
pub published: chrono::NaiveDateTime,
|
||||
|
@ -57,7 +55,6 @@ pub struct CommunityForm {
|
|||
pub name: String,
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub category_id: i32,
|
||||
pub creator_id: i32,
|
||||
pub removed: Option<bool>,
|
||||
pub published: Option<chrono::NaiveDateTime>,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
pub mod activity;
|
||||
pub mod category;
|
||||
pub mod comment;
|
||||
pub mod comment_report;
|
||||
pub mod community;
|
||||
|
|
|
@ -483,7 +483,6 @@ mod tests {
|
|||
name: "test community 5".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
creator_id: inserted_user.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
@ -625,7 +624,6 @@ mod tests {
|
|||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_user.id,
|
||||
category_id: 1,
|
||||
updated: None,
|
||||
banner: None,
|
||||
published: inserted_community.published,
|
||||
|
|
|
@ -479,7 +479,6 @@ mod tests {
|
|||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_user.id,
|
||||
category_id: 1,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
|
@ -614,7 +613,6 @@ mod tests {
|
|||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_user.id,
|
||||
category_id: 1,
|
||||
updated: None,
|
||||
banner: None,
|
||||
published: inserted_community.published,
|
||||
|
|
|
@ -12,9 +12,8 @@ use lemmy_db_queries::{
|
|||
ViewToVec,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
schema::{category, community, community_aggregates, community_follower, user_},
|
||||
schema::{community, community_aggregates, community_follower, user_},
|
||||
source::{
|
||||
category::Category,
|
||||
community::{Community, CommunityFollower, CommunitySafe},
|
||||
user::{UserSafe, User_},
|
||||
},
|
||||
|
@ -25,7 +24,6 @@ use serde::Serialize;
|
|||
pub struct CommunityView {
|
||||
pub community: CommunitySafe,
|
||||
pub creator: UserSafe,
|
||||
pub category: Category,
|
||||
pub subscribed: bool,
|
||||
pub counts: CommunityAggregates,
|
||||
}
|
||||
|
@ -33,7 +31,6 @@ pub struct CommunityView {
|
|||
type CommunityViewTuple = (
|
||||
CommunitySafe,
|
||||
UserSafe,
|
||||
Category,
|
||||
CommunityAggregates,
|
||||
Option<CommunityFollower>,
|
||||
);
|
||||
|
@ -47,10 +44,9 @@ impl CommunityView {
|
|||
// The left join below will return None in this case
|
||||
let user_id_join = my_user_id.unwrap_or(-1);
|
||||
|
||||
let (community, creator, category, counts, follower) = community::table
|
||||
let (community, creator, counts, follower) = community::table
|
||||
.find(community_id)
|
||||
.inner_join(user_::table)
|
||||
.inner_join(category::table)
|
||||
.inner_join(community_aggregates::table)
|
||||
.left_join(
|
||||
community_follower::table.on(
|
||||
|
@ -62,7 +58,6 @@ impl CommunityView {
|
|||
.select((
|
||||
Community::safe_columns_tuple(),
|
||||
User_::safe_columns_tuple(),
|
||||
category::all_columns,
|
||||
community_aggregates::all_columns,
|
||||
community_follower::all_columns.nullable(),
|
||||
))
|
||||
|
@ -71,7 +66,6 @@ impl CommunityView {
|
|||
Ok(CommunityView {
|
||||
community,
|
||||
creator,
|
||||
category,
|
||||
subscribed: follower.is_some(),
|
||||
counts,
|
||||
})
|
||||
|
@ -162,7 +156,6 @@ impl<'a> CommunityQueryBuilder<'a> {
|
|||
|
||||
let mut query = community::table
|
||||
.inner_join(user_::table)
|
||||
.inner_join(category::table)
|
||||
.inner_join(community_aggregates::table)
|
||||
.left_join(
|
||||
community_follower::table.on(
|
||||
|
@ -174,7 +167,6 @@ impl<'a> CommunityQueryBuilder<'a> {
|
|||
.select((
|
||||
Community::safe_columns_tuple(),
|
||||
User_::safe_columns_tuple(),
|
||||
category::all_columns,
|
||||
community_aggregates::all_columns,
|
||||
community_follower::all_columns.nullable(),
|
||||
))
|
||||
|
@ -235,9 +227,8 @@ impl ViewToVec for CommunityView {
|
|||
.map(|a| Self {
|
||||
community: a.0.to_owned(),
|
||||
creator: a.1.to_owned(),
|
||||
category: a.2.to_owned(),
|
||||
counts: a.3.to_owned(),
|
||||
subscribed: a.4.is_some(),
|
||||
counts: a.2.to_owned(),
|
||||
subscribed: a.3.is_some(),
|
||||
})
|
||||
.collect::<Vec<Self>>()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use lemmy_db_schema::source::{category::*, user::UserSafeSettings};
|
||||
use lemmy_db_schema::source::user::UserSafeSettings;
|
||||
use lemmy_db_views::{comment_view::CommentView, post_view::PostView, site_view::SiteView};
|
||||
use lemmy_db_views_actor::{community_view::CommunityView, user_view::UserViewSafe};
|
||||
use lemmy_db_views_moderator::{
|
||||
|
@ -14,14 +14,6 @@ use lemmy_db_views_moderator::{
|
|||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct ListCategories {}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ListCategoriesResponse {
|
||||
pub categories: Vec<Category>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Search {
|
||||
pub q: String,
|
||||
|
|
|
@ -88,7 +88,6 @@ pub enum UserOperation {
|
|||
CreateCommunity,
|
||||
CreatePost,
|
||||
ListCommunities,
|
||||
ListCategories,
|
||||
GetPost,
|
||||
GetCommunity,
|
||||
CreateComment,
|
||||
|
|
34
migrations/2021-02-25-112959_remove-categories/down.sql
Normal file
34
migrations/2021-02-25-112959_remove-categories/down.sql
Normal file
|
@ -0,0 +1,34 @@
|
|||
create table category (
|
||||
id serial primary key,
|
||||
name varchar(100) not null unique
|
||||
);
|
||||
|
||||
insert into category (name) values
|
||||
('Discussion'),
|
||||
('Humor/Memes'),
|
||||
('Gaming'),
|
||||
('Movies'),
|
||||
('TV'),
|
||||
('Music'),
|
||||
('Literature'),
|
||||
('Comics'),
|
||||
('Photography'),
|
||||
('Art'),
|
||||
('Learning'),
|
||||
('DIY'),
|
||||
('Lifestyle'),
|
||||
('News'),
|
||||
('Politics'),
|
||||
('Society'),
|
||||
('Gender/Identity/Sexuality'),
|
||||
('Race/Colonisation'),
|
||||
('Religion'),
|
||||
('Science/Technology'),
|
||||
('Programming/Software'),
|
||||
('Health/Sports/Fitness'),
|
||||
('Porn'),
|
||||
('Places'),
|
||||
('Meta'),
|
||||
('Other');
|
||||
|
||||
ALTER TABLE community ADD category_id int references category on update cascade on delete cascade not null default 1;
|
2
migrations/2021-02-25-112959_remove-categories/up.sql
Normal file
2
migrations/2021-02-25-112959_remove-categories/up.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE community DROP COLUMN category_id;
|
||||
DROP TABLE category;
|
|
@ -109,7 +109,6 @@ fn community_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
|||
name: ccommunity.name.to_owned(),
|
||||
title: ccommunity.title.to_owned(),
|
||||
description: ccommunity.description.to_owned(),
|
||||
category_id: ccommunity.category_id,
|
||||
creator_id: ccommunity.creator_id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
|
@ -127,7 +127,6 @@ fn create_community(conn: &PgConnection, creator_id: i32) -> Community {
|
|||
creator_id,
|
||||
title: "test_community".to_owned(),
|
||||
description: None,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
|
|
Loading…
Reference in a new issue