Re: Idempotent DDL Updates - Mailing list pgsql-general

From Julien Rouhaud
Subject Re: Idempotent DDL Updates
Date
Msg-id CAOBaU_ahhqLJAHk-GWu_zsx3m+vEWb6gbHt_7Stte8NdUTeCtg@mail.gmail.com
Whole thread Raw
In response to Idempotent DDL Updates  (Miles Elam <miles.elam@productops.com>)
Responses Re: Idempotent DDL Updates  (Miles Elam <miles.elam@productops.com>)
List pgsql-general
On Sat, Aug 28, 2021 at 2:19 AM Miles Elam <miles.elam@productops.com> wrote:
>
> What is the general consensus within the community on idempotent DDL scripts, ie. consistent usage of IF EXISTS/IF
NOTEXISTS/OR REPLACE for SQL init files that get checked into source control? 
> [...]
> The drawbacks I've run across are those areas where the EXISTS/REPLACE constructs aren't implemented like roles
management,domains, constraints, etc. However those cases seem to be handled with only minor increases in complexity
withjudicious use of inline plpgsql. 
>
> In others' opinions, has DDL idempotency been viable for maintenance of PG databases fo you in production?

Note that the IF EXISTS / IF NOT EXISTS are *not* idempotent.  If you
need to write idempotent schema update scripts, you need to query the
catalogs to check if the specific change you want to apply has already
been applied or not.



pgsql-general by date:

Previous
From: obi reddy
Date:
Subject: Re:
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: Can we get rid of repeated queries from pg_dump?