]> Untitled Git - lemmy.git/commitdiff
Remove categories (fixes #1429)
authorFelix Ableitner <me@nutomic.com>
Thu, 25 Feb 2021 12:16:58 +0000 (13:16 +0100)
committerFelix Ableitner <me@nutomic.com>
Thu, 25 Feb 2021 12:22:37 +0000 (13:22 +0100)
32 files changed:
crates/api/src/community.rs
crates/api/src/lib.rs
crates/api/src/routes.rs
crates/api/src/site.rs
crates/api/src/user.rs
crates/apub/src/extensions/group_extensions.rs
crates/apub/src/objects/community.rs
crates/db_queries/src/aggregates/comment_aggregates.rs
crates/db_queries/src/aggregates/community_aggregates.rs
crates/db_queries/src/aggregates/post_aggregates.rs
crates/db_queries/src/aggregates/site_aggregates.rs
crates/db_queries/src/aggregates/user_aggregates.rs
crates/db_queries/src/source/category.rs [deleted file]
crates/db_queries/src/source/comment.rs
crates/db_queries/src/source/community.rs
crates/db_queries/src/source/mod.rs
crates/db_queries/src/source/moderator.rs
crates/db_queries/src/source/post.rs
crates/db_queries/src/source/user_mention.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/category.rs [deleted file]
crates/db_schema/src/source/community.rs
crates/db_schema/src/source/mod.rs
crates/db_views/src/comment_view.rs
crates/db_views/src/post_view.rs
crates/db_views_actor/src/community_view.rs
crates/structs/src/site.rs
crates/websocket/src/lib.rs
migrations/2021-02-25-112959_remove-categories/down.sql [new file with mode: 0644]
migrations/2021-02-25-112959_remove-categories/up.sql [new file with mode: 0644]
src/code_migrations.rs
tests/integration_test.rs

index fcfe7913331743b0575c134309f0b5d8f3e550b2..128d8b3031d1519a68a2a0398a6b96dd273605e1 100644 (file)
@@ -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),
index 7f6fcb02973d303caf5011db62c898efa3f28a45..5642c4b9c7a31f0a9a744af2ac70e8a974a2062d 100644 (file)
@@ -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 => {
index a55dec5f2e57f28bde5e91c55822c76891c3f83b..7ca609f1ac40f668f81dfee3a836ddf834d1497e 100644 (file)
@@ -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())
index d9ed835eada32aa3b0ad7983fe8f165a737210b1..b545a72eabd78a108324b3dae7f1e0ee999ec31b 100644 (file)
@@ -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;
index dfe527db3ab71d33150e21379c6436001e0be6f6..c6877fe0de86f581b0df8826c6dd618938c835ca 100644 (file)
@@ -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,
index 891cb26c73cf28a229d46a3b04de629abaa3253b..face43cab8d457f1854416aa6b328304e7e8e196 100644 (file)
@@ -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(())
   }
index c6189f9c7572757ad1ad900279a74a7f21b6dc0c..827eae294607011306d7680aa708b9a5cd6407e9 100644 (file)
@@ -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()),
index 61984727183f9d2216d5a576dd5c3aaaa48ea348..a4db471b65343708a7188d5df6eb848abd901979 100644 (file)
@@ -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,
index baeaa759bf0d8c65bbd86247bf4f9fa24b770bad..f5cd577e437efef958d39f18e43bcb3692e78f40 100644 (file)
@@ -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,
index ffee93bec64dc533f5c50c50e16d694bbc9dca47..fa8b69255c755e88cac92cecc46b5714b73ac82a 100644 (file)
@@ -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,
index 125513656895a36ee49d7afe12582e9c9524b60e..46db2f0cd4eb926a05406b8f6195f32b2012c58f 100644 (file)
@@ -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,
index 8d232268c2e566817b70eace0ec496e5f5f35be9..fcda1d462cc76745baddb574203affa692136466 100644 (file)
@@ -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,
diff --git a/crates/db_queries/src/source/category.rs b/crates/db_queries/src/source/category.rs
deleted file mode 100644 (file)
index 2d9eeb3..0000000
+++ /dev/null
@@ -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]);
-  }
-}
index 3abff1c5d7b4ed2e4cda5f47f73482b093a968d8..709a8aa39b9bde3a4a20c5bedb20ee2ea95aaacf 100644 (file)
@@ -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,
index c2809a78f7e0a10ddbaffa8db93858deb531f7d2..08421bd5d67d3103b77af19687af01e858a66f68 100644 (file)
@@ -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,
index 211194a44ffa92e91eeaf2a4d2aeb9ad2db6295e..a39dc1108717decdb7b94e31134f4e563c53b538 100644 (file)
@@ -1,5 +1,4 @@
 pub mod activity;
-pub mod category;
 pub mod comment;
 pub mod comment_report;
 pub mod community;
index e3ee76328a8ce3a8d50e0239adb64b43e5ee76b5..9b6e58edf340eeee1a1ebc547fa4c020829bfc77 100644 (file)
@@ -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,
index ddb3702c23aca35622dc562161bac5b031c77add..1c19e53d0326aad41f2b437f682771858873b40e 100644 (file)
@@ -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,
index 93f0b86d0ea17b9566a59e66dec7ca8cb50f0d66..b0c97572f691193e03ed38399b1f7a7390e6ac9c 100644 (file)
@@ -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,
index 71232ebdb86edb71e67b1e80c79edcd3dacd9c20..3786e00ca6abb741fa01bd51b97d971054a5983b 100644 (file)
@@ -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,
diff --git a/crates/db_schema/src/source/category.rs b/crates/db_schema/src/source/category.rs
deleted file mode 100644 (file)
index ea2ff12..0000000
+++ /dev/null
@@ -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,
-}
index e05abf1b3738b414de36784b0b7f5037453f9841..b8702ca97d8b8fa2a49fd4732d03c20f8817948d 100644 (file)
@@ -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>,
index 211194a44ffa92e91eeaf2a4d2aeb9ad2db6295e..a39dc1108717decdb7b94e31134f4e563c53b538 100644 (file)
@@ -1,5 +1,4 @@
 pub mod activity;
-pub mod category;
 pub mod comment;
 pub mod comment_report;
 pub mod community;
index b2a9902a4e976b75930f781d9480f778354a7fc3..4f9a6a5f71ceae204cf80d69f968fed2f816ae05 100644 (file)
@@ -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,
index 54e28de1736ff87a2eb9b3aae375cc33dbd7cae9..ed1ef4ce1419158457ded6c966ecab6fb653878c 100644 (file)
@@ -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,
index 714fd65e8b3054ebaf3a9612949020c057c82998..9187696db1d8f42642af3e6ea357a43d0ad5f203 100644 (file)
@@ -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>>()
   }
index 22b44d73ce0efb98341e7b02b8880769a192c6b3..ef878ba523d3c1664f75bba552b8cdabdaf13c06 100644 (file)
@@ -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,
index 2144ffefb1c33fec62912a45a975f17138f68aa3..4723c7141b5c24e7ca103c815e884228a2ae1155 100644 (file)
@@ -88,7 +88,6 @@ pub enum UserOperation {
   CreateCommunity,
   CreatePost,
   ListCommunities,
-  ListCategories,
   GetPost,
   GetCommunity,
   CreateComment,
diff --git a/migrations/2021-02-25-112959_remove-categories/down.sql b/migrations/2021-02-25-112959_remove-categories/down.sql
new file mode 100644 (file)
index 0000000..9f1837b
--- /dev/null
@@ -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;
\ No newline at end of file
diff --git a/migrations/2021-02-25-112959_remove-categories/up.sql b/migrations/2021-02-25-112959_remove-categories/up.sql
new file mode 100644 (file)
index 0000000..ebe83e5
--- /dev/null
@@ -0,0 +1,2 @@
+ALTER TABLE community DROP COLUMN category_id;
+DROP TABLE category;
index 7478d5af72003f462730f4f57e9cd91189a08579..ea11e32d3be60b9c4f3a8fed2e64555f04b6aad4 100644 (file)
@@ -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,
index f205ceb51d70eea393503042a71737fe6089fc79..5f92dc6b73cfe5eb4d64896d29a5b2d81d7a200a 100644 (file)
@@ -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,