-- update the default sort type
UPDATE
    local_user
SET
    default_sort_type = 'TopDay'
WHERE
    default_sort_type IN ('TopHour', 'TopSixHour', 'TopTwelveHour');

-- rename the old enum
ALTER TYPE sort_type_enum RENAME TO sort_type_enum__;

-- create the new enum
CREATE TYPE sort_type_enum AS ENUM (
    'Active',
    'Hot',
    'New',
    'Old',
    'TopDay',
    'TopWeek',
    'TopMonth',
    'TopYear',
    'TopAll',
    'MostComments',
    'NewComments'
);

-- alter all you enum columns
ALTER TABLE local_user
    ALTER COLUMN default_sort_type TYPE sort_type_enum
    USING default_sort_type::text::sort_type_enum;

-- drop the old enum
DROP TYPE sort_type_enum__;

