-- Adds a category and a resolved flag to notes.
-- Existing rows are backfilled with the defaults (category 'Change', not resolved).

alter table notes add column if not exists category text not null default 'Change';
alter table notes add column if not exists resolved boolean not null default false;
alter table notes add column if not exists resolved_at timestamptz;

do $$ begin
  alter table notes add constraint notes_category_check
    check (category in ('Change', 'Bug', 'Question', 'Live Changelog'));
exception when duplicate_object then null;
end $$;
