update postgresjson

This commit is contained in:
2019-08-27 12:33:32 +02:00
parent 67665350eb
commit ff76bd55ef
29 changed files with 139 additions and 119 deletions

View File

@@ -1,19 +1,19 @@
create or replace function follow(reference regclass, _target_id uuid, _citizen_id uuid) returns void
create or replace function follow(reference regclass, _target_id uuid, _created_by_id uuid) returns void
language plpgsql as
$$
begin
if reference = 'article'::regclass then
insert into follow_article (citizen_id, target_id)
values (_citizen_id, _target_id)
on conflict (citizen_id, target_id) do nothing;
insert into follow_article (created_by_id, target_id)
values (_created_by_id, _target_id)
on conflict (created_by_id, target_id) do nothing;
elseif reference = 'constitution'::regclass then
insert into follow_constitution (citizen_id, target_id)
values (_citizen_id, _target_id)
on conflict (citizen_id, target_id) do nothing;
insert into follow_constitution (created_by_id, target_id)
values (_created_by_id, _target_id)
on conflict (created_by_id, target_id) do nothing;
elseif reference = 'citizen'::regclass then
insert into follow_citizen (citizen_id, target_id)
values (_citizen_id, _target_id)
on conflict (citizen_id, target_id) do nothing;
insert into follow_citizen (created_by_id, target_id)
values (_created_by_id, _target_id)
on conflict (created_by_id, target_id) do nothing;
else
raise exception '% no implemented', reference::text;
end if;