]> Untitled Git - lemmy.git/blob - migrations/2023-04-14-175955_add_listingtype_sorttype_enums/up.sql
Enhanced testing of comments. Validate reply notifications, mentions (#3686)
[lemmy.git] / migrations / 2023-04-14-175955_add_listingtype_sorttype_enums / up.sql
1 -- A few DB fixes
2 alter table community alter column hidden set not null;
3 alter table community alter column posting_restricted_to_mods set not null;
4 alter table activity alter column sensitive set not null;
5 alter table mod_add alter column removed set not null;
6 alter table mod_add_community alter column removed set not null;
7 alter table mod_ban alter column banned set not null;
8 alter table mod_ban_from_community alter column banned set not null;
9 alter table mod_hide_community alter column hidden set not null;
10 alter table mod_lock_post alter column locked set not null;
11 alter table mod_remove_comment alter column removed set not null;
12 alter table mod_remove_community alter column removed set not null;
13 alter table mod_remove_post alter column removed set not null;
14 alter table mod_transfer_community drop column removed;
15 alter table language alter column code set not null;
16 alter table language alter column name set not null;
17
18 -- Fix the registration mode enums
19 ALTER TYPE registration_mode_enum RENAME VALUE 'closed' TO 'Closed';
20 ALTER TYPE registration_mode_enum RENAME VALUE 'require_application' TO 'RequireApplication';
21 ALTER TYPE registration_mode_enum RENAME VALUE 'open' TO 'Open';
22
23 -- Create the enums
24
25 CREATE TYPE sort_type_enum AS ENUM ('Active', 'Hot', 'New', 'Old', 'TopDay', 'TopWeek', 'TopMonth', 'TopYear', 'TopAll', 'MostComments', 'NewComments');
26   
27 CREATE TYPE listing_type_enum AS ENUM ('All', 'Local', 'Subscribed');
28
29 -- Alter the local_user table
30 alter table local_user alter column default_sort_type drop default;
31 alter table local_user alter column default_sort_type type sort_type_enum using
32     case default_sort_type
33         when 0 then 'Active'
34         when 1 then 'Hot'
35         when 2 then 'New'
36         when 3 then 'Old'
37         when 4 then 'TopDay'
38         when 5 then 'TopWeek'
39         when 6 then 'TopMonth'
40         when 7 then 'TopYear'
41         when 8 then 'TopAll'
42         when 9 then 'MostComments'
43         when 10 then 'NewComments'
44         else 'Active'
45     end :: sort_type_enum;
46 alter table local_user alter column default_sort_type set default 'Active';
47
48 alter table local_user alter column default_listing_type drop default;
49 alter table local_user alter column default_listing_type type listing_type_enum using
50     case default_listing_type
51         when 0 then 'All'
52         when 1 then 'Local'
53         when 2 then 'Subscribed'
54         else 'Local'
55     end :: listing_type_enum;
56 alter table local_user alter column default_listing_type set default 'Local';
57
58 -- Alter the local site column
59 alter table local_site alter column default_post_listing_type drop default;
60 alter table local_site alter column default_post_listing_type type listing_type_enum using default_post_listing_type::listing_type_enum;
61 alter table local_site alter column default_post_listing_type set default 'Local';