create type STATUS as enum ('WAITING', 'REVIEWED', 'ACCEPTED');
create table peer_reviews (
  task_id text not null,
  comment text,
  score int,
  reviewer_id text not null,
  status STATUS not null
);

-- create types
DO $$
BEGIN
  IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'status') THEN
    CREATE TYPE status AS enum (
        'WAITING',
        'REVIEWED',
        'ACCEPTED'
    );
  END IF;
END$$;

-- create tables
CREATE TABLE IF NOT EXISTS peer_reviews (
  task_id text NOT NULL,
  comment text,
  score int,
  reviewer_id text NOT NULL,
  status STATUS NOT NULL
);

Use 'IF EXISTS' on db creation. This way it won't fail even when same migration is ran multiple times.
Use 'IF EXISTS' on db creation. This way it won't fail even when same migration is ran multiple times.
