-- cant run ALTER TYPE inside transaction block (migration runs in transaction block)
-- ALTER TYPE resource_type ADD VALUE IF NOT EXISTS 'RUBLE_BUDGET';

START TRANSACTION;

ALTER TYPE resource_type
  RENAME TO _resource_type;

CREATE TYPE resource_type AS ENUM ('ENUMERABLE', 'MEMORY', 'MONEY', 'POWER', 'STORAGE', 'TRAFFIC', 'BINARY_TRAFFIC', 'PROCESSOR', 'RUBLE_BUDGET');

ALTER TABLE resource
  ALTER COLUMN resource_type TYPE resource_type USING resource_type :: text :: resource_type;

DROP TYPE _resource_type;

COMMIT;
