-- 2023-09-06: Some improvements to posts

-- +migrate Up

alter table config add column post_character_limit integer not null default 5000;
create index posts_blog_id_idx on posts (blog_id);

create table post_recipients (
    post_id    TEXT NOT NULL REFERENCES posts (id) ON DELETE CASCADE,
    blog_id    TEXT NOT NULL REFERENCES blogs (id) ON DELETE CASCADE,

    PRIMARY KEY (post_id, blog_id)
);

-- +migrate Down

drop table post_recipients;
drop index posts_blog_id_idx;
alter table config drop column post_character_limit;
