Fix post set migration

This commit is contained in:
Kira 2020-01-16 10:12:33 -08:00
parent 621df484f5
commit 8e117f4a2f
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,4 @@
DROP TABLE IF EXISTS lol, restricted, table_data, servers, server_keys, stats, user_blacklisted_tags_backup, user_metadata;
DROP TABLE IF EXISTS posts_tags, locked_post_tags;
DROP TABLE IF EXISTS mod_menu, mod_queue_posts;
DROP TABLE IF EXISTS tag_subscriptions;

View File

@ -1,7 +1,16 @@
begin;
alter table set_maintainers rename to post_set_maintainers;
alter table post_sets rename column transfer_to_parent_on_delete to transfer_on_delete;
alter table post_sets rename column public to is_public;
alter table post_sets rename column user_id to creator_id;
alter table post_sets add column creator_ip_addr inet,
add column post_ids integer[] not null default '{}'::integer[];
add column post_ids integer[] not null default '{}'::integer[];
create index set_posts on set_entries(post_set_id);
update post_sets set post_ids = (select coalesce(array_agg(x.post_id), '{}'::integer[]) from (select _.post_id from set_entries _ where _.post_set_id = post_sets.id order by _.position) x);
UPDATE post_sets SET post_count = COALESCE(array_length(post_ids, 1), 0);
drop index set_posts;
drop table set_entries;
commit;