How I can aggregate the generated json for postgresql in order to be able more easily to copy-paste it into pg-diff config

Dimitrios Desyllas - Jan 28 '21 - - Dev Community

As I asked upon:

https://dba.stackexchange.com/q/284165/118215

Using that query:

select 
        table_name::text as table_name ,
        json_build_object(
            'tableName'::text,table_name::text,
            'tableSchema'::text,table_schema::text,
            'tableKeyFields'::text,jsonb_agg(column_name::text)
        ) as table_info
    FROM 
        information_schema.columns
    WHERE 
        table_schema = 'public'
    group by 
        table_name,table_schema;
Enter fullscreen mode Exit fullscreen mode

I managed to generate the json required for each table in order to place it into pg-diff's config.

But I want the results of the query's mentioned above to be aggrregated into a single string that is \n, seperated so I can easily copy-pasted it from my tool into pg-diff's config file: pg-diff-config.json.

Do you know how I can do that?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player