mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 08:11:20 +00:00
Nutomic
2ef0f8f5f8
* implement language tags for site/community in db and api * add api checks for valid languages * during db migration, update existing users, sites, communities to have all languages enabled * init new users/communities with site languages (not all languages) * federate site/community languages * fix tests * when updating site languages, limit community languages to this subset also, when making a new post and subset of user lang, community lang contains only one item, use that as post lang * add tests for actor_language db functions * include language list in siteview/communityview * Fix some of the review comments * Some more review changes * Add todo about boxed query * Add default_post_language to GetCommunityResponse
38 lines
1.2 KiB
SQL
38 lines
1.2 KiB
SQL
create table site_language (
|
|
id serial primary key,
|
|
site_id int references site on update cascade on delete cascade not null,
|
|
language_id int references language on update cascade on delete cascade not null,
|
|
unique (site_id, language_id)
|
|
);
|
|
|
|
create table community_language (
|
|
id serial primary key,
|
|
community_id int references community on update cascade on delete cascade not null,
|
|
language_id int references language on update cascade on delete cascade not null,
|
|
unique (community_id, language_id)
|
|
);
|
|
|
|
-- update existing users, sites and communities to have all languages enabled
|
|
do $$
|
|
declare
|
|
xid integer;
|
|
begin
|
|
for xid in select id from local_user
|
|
loop
|
|
insert into local_user_language (local_user_id, language_id)
|
|
(select xid, language.id as lid from language);
|
|
end loop;
|
|
|
|
for xid in select id from site
|
|
loop
|
|
insert into site_language (site_id, language_id)
|
|
(select xid, language.id as lid from language);
|
|
end loop;
|
|
|
|
for xid in select id from community
|
|
loop
|
|
insert into community_language (community_id, language_id)
|
|
(select xid, language.id as lid from language);
|
|
end loop;
|
|
end;
|
|
$$;
|