lemmy/migrations/2023-06-20-191145_add_listingtype_sorttype_3_6_9_months_enums/down.sql
Dessalines be1389420b
Adding SQL format checking via pg_format / pgFormatter (#3740)
* SQL format checking, 1.

* SQL format checking, 2.

* SQL format checking, 3.

* SQL format checking, 4.

* SQL format checking, 5.

* Running pg_format

* Getting rid of comment.

* Upping pg_format version.

* Using git ls-files for sql format check.

* Fixing sql lints.

* Addressing PR comments.
2023-08-02 12:44:51 -04:00

38 lines
741 B
SQL

-- update the default sort type
UPDATE
local_user
SET
default_sort_type = 'TopDay'
WHERE
default_sort_type IN ('TopThreeMonths', 'TopSixMonths', 'TopNineMonths');
-- 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',
'TopHour',
'TopSixHour',
'TopTwelveHour'
);
-- 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__;