]> Untitled Git - lemmy.git/commitdiff
Removing fast tables and old views.
authorDessalines <tyhou13@gmx.com>
Thu, 17 Dec 2020 03:42:25 +0000 (22:42 -0500)
committerDessalines <tyhou13@gmx.com>
Thu, 17 Dec 2020 03:42:25 +0000 (22:42 -0500)
docker/docker_db_backup.sh
lemmy_db/Cargo.toml
lemmy_db/src/schema.rs
migrations/2020-12-17-030456_create_alias_views/down.sql [new file with mode: 0644]
migrations/2020-12-17-030456_create_alias_views/up.sql [new file with mode: 0644]
migrations/2020-12-17-031053_remove_fast_tables_and_views/down.sql [new file with mode: 0644]
migrations/2020-12-17-031053_remove_fast_tables_and_views/up.sql [new file with mode: 0644]

index d42826e06d6123dd8d53af3b2235d69e94387a03..e9473a29027108716c28c503ac86ef581f05f2b3 100755 (executable)
@@ -1 +1,4 @@
-docker exec -it dev_lemmy_db_1 pg_dumpall -c -U rrr > dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql
+#!/bin/bash
+pushd dev
+docker-compose exec postgres pg_dumpall -c -U lemmy > dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql
+popd
index 11b27fcd7dfa16f818bb31dea33e48e396e0f151..d7c0fe3b0ee7c018df756bfaaf0515b69186b701 100644 (file)
@@ -9,7 +9,7 @@ path = "src/lib.rs"
 
 [dependencies]
 lemmy_utils = { path = "../lemmy_utils" }
-diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","64-column-tables","serde_json"] }
+diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] }
 chrono = { version = "0.4.19", features = ["serde"] }
 serde = { version = "1.0.118", features = ["derive"] }
 serde_json = { version = "1.0.60", features = ["preserve_order"] }
index 75883df577b7a408748a6599b05ecbb9d96763e7..33e2389fdb929be0ee7d4954d03fc7b45e8f8a34 100644 (file)
@@ -44,42 +44,6 @@ table! {
     }
 }
 
-table! {
-    comment_aggregates_fast (id) {
-        id -> Int4,
-        creator_id -> Nullable<Int4>,
-        post_id -> Nullable<Int4>,
-        parent_id -> Nullable<Int4>,
-        content -> Nullable<Text>,
-        removed -> Nullable<Bool>,
-        read -> Nullable<Bool>,
-        published -> Nullable<Timestamp>,
-        updated -> Nullable<Timestamp>,
-        deleted -> Nullable<Bool>,
-        ap_id -> Nullable<Varchar>,
-        local -> Nullable<Bool>,
-        post_name -> Nullable<Varchar>,
-        community_id -> Nullable<Int4>,
-        community_actor_id -> Nullable<Varchar>,
-        community_local -> Nullable<Bool>,
-        community_name -> Nullable<Varchar>,
-        community_icon -> Nullable<Text>,
-        banned -> Nullable<Bool>,
-        banned_from_community -> Nullable<Bool>,
-        creator_actor_id -> Nullable<Varchar>,
-        creator_local -> Nullable<Bool>,
-        creator_name -> Nullable<Varchar>,
-        creator_preferred_username -> Nullable<Varchar>,
-        creator_published -> Nullable<Timestamp>,
-        creator_avatar -> Nullable<Text>,
-        score -> Nullable<Int8>,
-        upvotes -> Nullable<Int8>,
-        downvotes -> Nullable<Int8>,
-        hot_rank -> Nullable<Int4>,
-        hot_rank_active -> Nullable<Int4>,
-    }
-}
-
 table! {
     comment_like (id) {
         id -> Int4,
@@ -147,37 +111,6 @@ table! {
     }
 }
 
-table! {
-    community_aggregates_fast (id) {
-        id -> Int4,
-        name -> Nullable<Varchar>,
-        title -> Nullable<Varchar>,
-        icon -> Nullable<Text>,
-        banner -> Nullable<Text>,
-        description -> Nullable<Text>,
-        category_id -> Nullable<Int4>,
-        creator_id -> Nullable<Int4>,
-        removed -> Nullable<Bool>,
-        published -> Nullable<Timestamp>,
-        updated -> Nullable<Timestamp>,
-        deleted -> Nullable<Bool>,
-        nsfw -> Nullable<Bool>,
-        actor_id -> Nullable<Varchar>,
-        local -> Nullable<Bool>,
-        last_refreshed_at -> Nullable<Timestamp>,
-        creator_actor_id -> Nullable<Varchar>,
-        creator_local -> Nullable<Bool>,
-        creator_name -> Nullable<Varchar>,
-        creator_preferred_username -> Nullable<Varchar>,
-        creator_avatar -> Nullable<Text>,
-        category_name -> Nullable<Varchar>,
-        number_of_subscribers -> Nullable<Int8>,
-        number_of_posts -> Nullable<Int8>,
-        number_of_comments -> Nullable<Int8>,
-        hot_rank -> Nullable<Int4>,
-    }
-}
-
 table! {
     community_follower (id) {
         id -> Int4,
@@ -351,52 +284,6 @@ table! {
     }
 }
 
-table! {
-    post_aggregates_fast (id) {
-        id -> Int4,
-        name -> Nullable<Varchar>,
-        url -> Nullable<Text>,
-        body -> Nullable<Text>,
-        creator_id -> Nullable<Int4>,
-        community_id -> Nullable<Int4>,
-        removed -> Nullable<Bool>,
-        locked -> Nullable<Bool>,
-        published -> Nullable<Timestamp>,
-        updated -> Nullable<Timestamp>,
-        deleted -> Nullable<Bool>,
-        nsfw -> Nullable<Bool>,
-        stickied -> Nullable<Bool>,
-        embed_title -> Nullable<Text>,
-        embed_description -> Nullable<Text>,
-        embed_html -> Nullable<Text>,
-        thumbnail_url -> Nullable<Text>,
-        ap_id -> Nullable<Varchar>,
-        local -> Nullable<Bool>,
-        creator_actor_id -> Nullable<Varchar>,
-        creator_local -> Nullable<Bool>,
-        creator_name -> Nullable<Varchar>,
-        creator_preferred_username -> Nullable<Varchar>,
-        creator_published -> Nullable<Timestamp>,
-        creator_avatar -> Nullable<Text>,
-        banned -> Nullable<Bool>,
-        banned_from_community -> Nullable<Bool>,
-        community_actor_id -> Nullable<Varchar>,
-        community_local -> Nullable<Bool>,
-        community_name -> Nullable<Varchar>,
-        community_icon -> Nullable<Text>,
-        community_removed -> Nullable<Bool>,
-        community_deleted -> Nullable<Bool>,
-        community_nsfw -> Nullable<Bool>,
-        number_of_comments -> Nullable<Int8>,
-        score -> Nullable<Int8>,
-        upvotes -> Nullable<Int8>,
-        downvotes -> Nullable<Int8>,
-        hot_rank -> Nullable<Int4>,
-        hot_rank_active -> Nullable<Int4>,
-        newest_activity_time -> Nullable<Timestamp>,
-    }
-}
-
 table! {
     post_like (id) {
         id -> Int4,
@@ -532,30 +419,6 @@ table! {
     }
 }
 
-table! {
-    user_fast (id) {
-        id -> Int4,
-        actor_id -> Nullable<Varchar>,
-        name -> Nullable<Varchar>,
-        preferred_username -> Nullable<Varchar>,
-        avatar -> Nullable<Text>,
-        banner -> Nullable<Text>,
-        email -> Nullable<Text>,
-        matrix_user_id -> Nullable<Text>,
-        bio -> Nullable<Text>,
-        local -> Nullable<Bool>,
-        admin -> Nullable<Bool>,
-        banned -> Nullable<Bool>,
-        show_avatars -> Nullable<Bool>,
-        send_notifications_to_email -> Nullable<Bool>,
-        published -> Nullable<Timestamp>,
-        number_of_posts -> Nullable<Int8>,
-        post_score -> Nullable<Int8>,
-        number_of_comments -> Nullable<Int8>,
-        comment_score -> Nullable<Int8>,
-    }
-}
-
 table! {
     user_mention (id) {
         id -> Int4,
@@ -707,13 +570,11 @@ allow_tables_to_appear_in_same_query!(
   category,
   comment,
   comment_aggregates,
-  comment_aggregates_fast,
   comment_like,
   comment_report,
   comment_saved,
   community,
   community_aggregates,
-  community_aggregates_fast,
   community_follower,
   community_moderator,
   community_user_ban,
@@ -729,7 +590,6 @@ allow_tables_to_appear_in_same_query!(
   password_reset_request,
   post,
   post_aggregates,
-  post_aggregates_fast,
   post_like,
   post_read,
   post_report,
@@ -740,7 +600,6 @@ allow_tables_to_appear_in_same_query!(
   user_,
   user_aggregates,
   user_ban,
-  user_fast,
   user_mention,
   comment_alias_1,
   user_alias_1,
diff --git a/migrations/2020-12-17-030456_create_alias_views/down.sql b/migrations/2020-12-17-030456_create_alias_views/down.sql
new file mode 100644 (file)
index 0000000..66ded96
--- /dev/null
@@ -0,0 +1 @@
+drop view user_alias_1, user_alias_2, comment_alias_1;
diff --git a/migrations/2020-12-17-030456_create_alias_views/up.sql b/migrations/2020-12-17-030456_create_alias_views/up.sql
new file mode 100644 (file)
index 0000000..3d3b1b4
--- /dev/null
@@ -0,0 +1,7 @@
+-- Some view that act as aliases 
+-- unfortunately necessary, since diesel doesn't have self joins
+-- or alias support yet
+create view user_alias_1 as select * from user_;
+create view user_alias_2 as select * from user_;
+create view comment_alias_1 as select * from comment;
+
diff --git a/migrations/2020-12-17-031053_remove_fast_tables_and_views/down.sql b/migrations/2020-12-17-031053_remove_fast_tables_and_views/down.sql
new file mode 100644 (file)
index 0000000..1c5d776
--- /dev/null
@@ -0,0 +1,4 @@
+-- There is no restore for this, it would require every view, table, index, etc.
+-- If you want to save past this point, you should make a DB backup.
+
+select * from user_ limit 1;
diff --git a/migrations/2020-12-17-031053_remove_fast_tables_and_views/up.sql b/migrations/2020-12-17-031053_remove_fast_tables_and_views/up.sql
new file mode 100644 (file)
index 0000000..803a5c4
--- /dev/null
@@ -0,0 +1,41 @@
+-- Drop views
+drop view if exists
+comment_aggregates_view, 
+comment_fast_view,
+comment_report_view,
+comment_view,
+community_aggregates_view,
+community_fast_view,
+community_follower_view,
+community_moderator_view,
+community_user_ban_view,
+community_view,
+mod_add_community_view,
+mod_add_view,
+mod_ban_from_community_view,
+mod_ban_view,
+mod_lock_post_view,
+mod_remove_comment_view,
+mod_remove_community_view,
+mod_remove_post_view,
+mod_sticky_post_view,
+post_aggregates_view,
+post_fast_view,
+post_report_view,
+post_view,
+private_message_view,
+reply_fast_view,
+site_view,
+user_mention_fast_view,
+user_mention_view,
+user_view
+cascade;
+
+-- Drop fast tables
+drop table if exists
+comment_aggregates_fast,
+community_aggregates_fast,
+post_aggregates_fast,
+user_fast
+cascade;
+