From d3992dadac634d48cc8342951979b8444b165df2 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 20 Sep 2012 19:21:23 -0400 Subject: [PATCH] sql fixes --- script/trim.sql | 4 ++-- script/upgrade_schema.sql | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/script/trim.sql b/script/trim.sql index 95661ab4b..c26b482d3 100644 --- a/script/trim.sql +++ b/script/trim.sql @@ -1,4 +1,4 @@ set statement_timeout = 0; -delete from posts where id < 1140000; -delete from post_appeals where post_id < 1140000; +delete from posts where id < (select max(id) - 50000 from posts); +delete from post_appeals where post_id < (select max(id) - 50000 from posts); vacuum analyze; diff --git a/script/upgrade_schema.sql b/script/upgrade_schema.sql index 5b45b026b..8315ab8c4 100755 --- a/script/upgrade_schema.sql +++ b/script/upgrade_schema.sql @@ -1,11 +1,8 @@ alter table posts add column fav_string text not null default ''; alter table posts add column pool_string text not null default ''; --- TODO: REVERT -update posts set fav_string = (select coalesce(array_to_string(array_agg('fav:' || _.user_id), ' '), '') from favorites _ where _.post_id = posts.id) where posts.id < 1000; - --- TODO: REVERT -update posts set pool_string = (select coalesce(array_to_string(array_agg('pool:' || _.pool_id), ' '), '') from pools_posts _ where _.post_id = posts.id) where posts.id < 1000; +update posts set fav_string = (select coalesce(array_to_string(array_agg('fav:' || _.user_id), ' '), '') from favorites _ where _.post_id = posts.id); +update posts set pool_string = (select coalesce(array_to_string(array_agg('pool:' || _.pool_id), ' '), '') from pools_posts _ where _.post_id = posts.id); create index index_advertisements_on_ad_type on advertisements (ad_type); @@ -3324,6 +3321,13 @@ COPY schema_migrations (version) FROM stdin; 20111101212358 \. +-- reindex +update posts set id = id; +update artists set id = id; +update dmails set id = id; +update forum_topics set id = id; +update forum_posts set id = id; + -- post processing drop table pools_posts; drop function pools_posts_delete_trg();