1 -- Drop the 2 views user_alias_1, user_alias_2
2 drop view user_alias_1, user_alias_2;
4 -- rename the user_ table to person
5 alter table user_ rename to person;
7 -- create a new table local_user
8 create table local_user (
10 user_id int references person on update cascade on delete cascade not null,
11 password_encrypted text not null,
13 admin boolean default false not null,
14 show_nsfw boolean default false not null,
15 theme character varying(20) default 'darkly'::character varying not null,
16 default_sort_type smallint default 0 not null,
17 default_listing_type smallint default 1 not null,
18 lang character varying(20) default 'browser'::character varying not null,
19 show_avatars boolean default true not null,
20 send_notifications_to_email boolean default false not null,
25 -- Copy the local users over to the new table
26 insert into local_user
38 send_notifications_to_email,
52 send_notifications_to_email,
57 -- Drop those columns from person
59 drop column password_encrypted,
62 drop column show_nsfw,
64 drop column default_sort_type,
65 drop column default_listing_type,
67 drop column show_avatars,
68 drop column send_notifications_to_email,
69 drop column matrix_user_id;
72 alter index user__pkey rename to person__pkey;
73 alter index idx_user_actor_id rename to idx_person_actor_id;
74 alter index idx_user_inbox_url rename to idx_person_inbox_url;
75 alter index idx_user_lower_actor_id rename to idx_person_lower_actor_id;
76 alter index idx_user_published rename to idx_person_published;
79 alter trigger site_aggregates_user_delete on person rename to site_aggregates_person_delete;
80 alter trigger site_aggregates_user_insert on person rename to site_aggregates_person_insert;
81 alter trigger user_aggregates_user on person rename to person_aggregates_person;
83 -- Rename the trigger functions
84 alter function site_aggregates_user_delete() rename to site_aggregates_person_delete;
85 alter function site_aggregates_user_insert() rename to site_aggregates_person_insert;
86 alter function user_aggregates_user() rename to person_aggregates_person;
89 create view person_alias_1 as select * from person;
90 create view person_alias_2 as select * from person;
92 -- Rename every user_id column to person_id