Removing fast tables and old views.

pull/1329/head
Dessalines 2020-12-16 22:42:25 -05:00
parent 05c3e471ae
commit 4f5e51beb5
7 changed files with 58 additions and 143 deletions

View File

@ -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

View 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"] }

View 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,

View File

@ -0,0 +1 @@
drop view user_alias_1, user_alias_2, comment_alias_1;

View File

@ -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;

View File

@ -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;

View File

@ -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;