-- Add up migration script here
BEGIN;
DROP INDEX IF EXISTS post_summary_idx;
ALTER TABLE post ADD search_summary TEXT;
CREATE INDEX post_search_summary_idx ON post USING gin (
    to_tsvector('english', search_summary)
);
UPDATE post SET search_summary = regexp_replace(
    regexp_replace(summary, '<[^>]+>', ' ', 'g'),
    '\s+',
    ' ',
    'g'
);
COMMIT;
