On 13 June 2013 04:30, Peter Eisentraut <pete...@gmx.net> wrote: > I'm wondering where "IF NOT EXISTS" and "OR REPLACE" will meet. >
CREATE OR REPLACE (or ALTER / UPDATE ?) would definitely be useful for enums, where it would be nice if we could teach an ORM to generate DDL based on the current values of the enum in code, and know that after the operation had completed, the database enum type matched the code enum type. I don't think a sequence of ALTER TYPE ADD VALUE IF NOT EXISTS quite does the trick, as it doesn't guarantee that the db enum is in the same order as the code enum, which may or may not be important. I'd expect a CREATE OR ALTER for enums to raise an error if any of the elements were out of order. Currently to get to a known state for enums you have to write manual migration scripts, and while that tends to be how I roll anyway, often when starting projects in rails / grails / hibernate etc people rely on db schemas generated by the framework as it lets them prototype with less mucking around. It would be nice for those frameworks to be able to generate enum types in a known state. Cheers Tom