-- Store meeting statuses as a fixed database enum instead of free-form text.
CREATE TYPE "MeetingStatus" AS ENUM ('DRAFT', 'SCHEDULED', 'SUBMITTED');

ALTER TABLE "meetings" ALTER COLUMN "status" DROP DEFAULT;

ALTER TABLE "meetings"
  ALTER COLUMN "status" TYPE "MeetingStatus"
  USING (
    CASE
      WHEN UPPER("status") IN ('DRAFT', 'DRAFTED') THEN 'DRAFT'::"MeetingStatus"
      WHEN UPPER("status") IN ('SCHEDULE', 'SCHEDULED') THEN 'SCHEDULED'::"MeetingStatus"
      ELSE 'SUBMITTED'::"MeetingStatus"
    END
  );

ALTER TABLE "meetings"
  ALTER COLUMN "status" SET DEFAULT 'DRAFT'::"MeetingStatus";
