- def alter_column_nwr_enum (table_name, column)
- response = select_one("select count(*) as count from pg_type where typname = 'nwr_enum'")
- if response['count'] == "0" #yep, as a string
- execute "create type nwr_enum as ENUM ('Node', 'Way', 'Relation')"
- end
- execute "alter table #{table_name} drop #{column}"
- execute "alter table #{table_name} add #{column} nwr_enum"
+ def enumerations
+ @enumerations ||= Hash.new
+ end
+
+ def create_enumeration(enumeration_name, values)
+ enumerations[enumeration_name] = values
+ execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')"
+ end
+
+ def drop_enumeration(enumeration_name)
+ execute "DROP TYPE #{enumeration_name}"
+ enumerations.delete(enumeration_name)
+ end
+
+ def rename_enumeration(old_name, new_name)
+ execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"