Re: Add column with If Not Exists

From: Dmitry Igrishin <dmitigr(at)gmail(dot)com>
To: simonwhite(at)dciphercomputing(dot)com
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Add column with If Not Exists
Date: 2018-08-04 17:45:27
Message-ID: CAAfz9KNGcV2gwFt0J9FmmfGhK-W9rJpuMaGkh0uPpC9YyHnuaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

сб, 4 авг. 2018 г. в 18:57, Simon White <simonwhite(at)dciphercomputing(dot)com>:
>
> Hi
>
> I would like to suggest the addition of the "If not exists" to the Add
> Column feature of Postgres. There are quite common situations where
> ensuring a column exists is important so that an update to remote
> devices will not fail but it is not so important that deprecated fields
> be removed. This is often the case with backward compatibility. New
> columns will not affect old systems but allows all remote devices
> running older software to be updated using the same process as new
> devices. Once the hardware reaches end of life it will be replaced and
> the new hardware will use the new columns. So having the ability to
> Alter the table with a series of Add Column commands ensures that the
> new records included in the update are added to the table. Having the
> "if not exists" would remove all of this potential complexity and allows
> a quick and easy method to ensure the column exists in the table using
> simple SQL commands that will not cause errors if the column is already
> present.
Hi Simon !

Recently I've released a tool that can be used to bypass errors like
("object already exists")
Please, take a look at https://github.com/dmitigr/pgspa
Feel free to contact me for any question about this tool.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brent Kerby 2018-08-04 19:34:04 Walsender waiting on SnapbuildSync
Previous Message Adrian Klaver 2018-08-04 17:41:11 Re: Add column with If Not Exists