Created
July 5, 2012 15:01
-
-
Save fredj/3054199 to your computer and use it in GitHub Desktop.
postgresql update enum (< 9.1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN; | |
ALTER TABLE missionevents ADD COLUMN type_text text; | |
UPDATE missionevents SET type_text = type::text; | |
DROP TYPE missionevent_type CASCADE; | |
CREATE TYPE missionevent_type AS ENUM ('location', 'battery_level', 'start', 'end', 'cancel', 'light', 'expire', 'battery_low', 'comment', 'warning', 'error', 'temperature_list', 'temperature_low', 'temperature_high'); | |
ALTER TABLE missionevents ADD COLUMN type missionevent_type; | |
UPDATE missionevents SET type = type_text::missionevent_type; | |
ALTER TABLE missionevents DROP COLUMN type_text; | |
ROLLBACK; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment