|
|
@@ -158,16 +158,20 @@ DROP TRIGGER IF EXISTS es_update_dataset on public.dataset; |
|
|
|
CREATE OR REPLACE FUNCTION public.update_dataset() RETURNS trigger AS |
|
|
|
$def$ |
|
|
|
BEGIN |
|
|
|
UPDATE public.dataset_es |
|
|
|
SET description=NEW.description, |
|
|
|
title=NEW.title, |
|
|
|
category=NEW.category, |
|
|
|
task=NEW.task, |
|
|
|
download_times=NEW.download_times, |
|
|
|
updated_unix=NEW.updated_unix, |
|
|
|
file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false), |
|
|
|
file_desc=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false) |
|
|
|
where id=NEW.id; |
|
|
|
if (NEW.status=0) then |
|
|
|
delete from public.dataset_es where id=NEW.id; |
|
|
|
elsif (NEW.status=1) then |
|
|
|
UPDATE public.dataset_es |
|
|
|
SET description=NEW.description, |
|
|
|
title=NEW.title, |
|
|
|
category=NEW.category, |
|
|
|
task=NEW.task, |
|
|
|
download_times=NEW.download_times, |
|
|
|
updated_unix=NEW.updated_unix, |
|
|
|
file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false), |
|
|
|
file_desc=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false) |
|
|
|
where id=NEW.id; |
|
|
|
end if; |
|
|
|
return new; |
|
|
|
END |
|
|
|
$def$ |
|
|
|