Re: JSONB filed with default JSON from a file

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: mrcasablr(at)gmail(dot)com
Cc: Charles Clavadetscher <clavadetscher(at)swisspug(dot)org>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: JSONB filed with default JSON from a file
Date: 2018-08-13 18:00:56
Message-ID: CAHyXU0zcM_S+7CtObiSEUr0W1COue6LcjSvDz4u7w-NPUexfjw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Aug 13, 2018 at 12:56 PM mrcasa bengaluru <mrcasablr(at)gmail(dot)com> wrote:
>>
>> I assume that you could declare the column as
>>
>> address jsonb not null default 'your json here'::jsonb;
>
>
> Thanks! However, this involves writing the entire JSON in the schema file looks inconvenient. I was hoping I would be able to reference to an external JSON file which could be used for the default value.

1) Stick the default json in a table somewhere, say default_json with
one row, one column
2) Wrap the table with a function, default_json() that returns the
value from the table
3) Make a default function for the table, DEFAULT default_json().
That way you externalize the default into the database

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-08-13 18:11:14 Re: JSONB filed with default JSON from a file
Previous Message mrcasa bengaluru 2018-08-13 17:55:48 Re: JSONB filed with default JSON from a file