ALTER TABLE "ImplantCatalog"
ADD COLUMN IF NOT EXISTS "isValve" BOOLEAN NOT NULL DEFAULT true;

ALTER TABLE "Device"
ADD COLUMN IF NOT EXISTS "isValve" BOOLEAN NOT NULL DEFAULT true;

UPDATE "ImplantCatalog"
SET "isPressureAdjustable" = CASE
  WHEN "isValve" THEN true
  ELSE false
END
WHERE "isPressureAdjustable" IS DISTINCT FROM CASE
  WHEN "isValve" THEN true
  ELSE false
END;

UPDATE "Device"
SET "isPressureAdjustable" = CASE
  WHEN "isValve" THEN true
  ELSE false
END
WHERE "isPressureAdjustable" IS DISTINCT FROM CASE
  WHEN "isValve" THEN true
  ELSE false
END;
