psql $(DATABASE) -v ON_ERROR_STOP=1<<<'copy (select temp_filters.jsonb_object_agg(object) from temp_filters.filter_search_json group by filter_id) to stdout;' > filters.jsonl
insert into temp_filters.filter_search_json (filter_id, object)select f.id, jsonb_build_object('creator', lower(u.name)) from filters f left join users u on f.user_id=u.id;
SQL
filter_search_json:
psql $(DATABASE) -v ON_ERROR_STOP=1 <<-SQL
drop schema if exists temp_filters cascade;
create schema temp_filters;
create unlogged table temp_filters.filter_search_json (filter_id bigint not null, object jsonb not null);
create or replace aggregate temp_filters.jsonb_object_agg(jsonb)(sfunc='jsonb_concat', stype= jsonb, initcond='{}');