sql fixes

This commit is contained in:
albert
2012-09-20 19:21:23 -04:00
parent 72cc2ee1ef
commit d3992dadac
2 changed files with 11 additions and 7 deletions

View File

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

View File

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