]> Untitled Git - lemmy.git/blob - migrations/2023-04-14-175955_add_listingtype_sorttype_enums/down.sql
Optimize hot rank updates (#3617)
[lemmy.git] / migrations / 2023-04-14-175955_add_listingtype_sorttype_enums / down.sql
1 -- Some fixes
2 alter table community alter column hidden drop not null;
3 alter table community alter column posting_restricted_to_mods drop not null;
4 alter table activity alter column sensitive drop not null;
5 alter table mod_add alter column removed drop not null;
6 alter table mod_add_community alter column removed drop not null;
7 alter table mod_ban alter column banned drop not null;
8 alter table mod_ban_from_community alter column banned drop not null;
9 alter table mod_hide_community alter column hidden drop not null;
10 alter table mod_lock_post alter column locked drop not null;
11 alter table mod_remove_comment alter column removed drop not null;
12 alter table mod_remove_community alter column removed drop not null;
13 alter table mod_remove_post alter column removed drop not null;
14 alter table mod_transfer_community add column removed boolean default false;
15 alter table language alter column code drop not null;
16 alter table language alter column name drop 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 'RequireApplication' TO 'require_application';
21 ALTER TYPE registration_mode_enum RENAME VALUE 'Open' TO 'open';
22
23 -- add back old columns
24
25 -- Alter the local_user table
26 alter table local_user alter column default_sort_type drop default;
27 alter table local_user alter column default_sort_type type smallint using
28     case default_sort_type
29         when 'Active' then 0
30         when 'Hot' then 1
31         when 'New' then 2
32         when 'Old' then 3
33         when 'TopDay' then 4
34         when 'TopWeek' then 5
35         when 'TopMonth' then 6
36         when 'TopYear' then 7
37         when 'TopAll' then 8
38         when 'MostComments' then 9
39         when 'NewComments' then 10
40         else 0
41     end;
42 alter table local_user alter column default_sort_type set default 0;
43
44 alter table local_user alter column default_listing_type drop default;
45 alter table local_user alter column default_listing_type type smallint using
46     case default_listing_type
47         when 'All' then 0
48         when 'Local' then 1
49         when 'Subscribed' then 2
50         else 1
51     end;
52 alter table local_user alter column default_listing_type set default 1;
53
54 -- Alter the local site column
55
56 alter table local_site alter column default_post_listing_type drop default;
57 alter table local_site alter column default_post_listing_type type text;
58 alter table local_site alter column default_post_listing_type set default 1;
59
60 -- Drop the types
61 drop type listing_type_enum;
62 drop type sort_type_enum;