Search Postgresql Archives

Re: conditionally executing migration code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Can't you just try to add the column and catch the error?  If you're
in a transaction use a user defined function to run it an catch the
exception in pl/pgsql.

On Thu, Jun 5, 2008 at 12:15 PM, Michael P. Soulier
<michael_soulier@xxxxxxxxx> wrote:
> I'm using some simple migration code to execute individual fragments of SQL
> code based on the version of the schema. Is there a way to perform an ALTER
> TABLE conditionally?
>
> Example:
>
> I want to add column foo to table bar, but only if column foo does not exist
> already.
>
> I'm trying to avoid such situations, but it's not always easy.
>
> Thanks,
> Mike
> --
> Michael P. Soulier <michael_soulier@xxxxxxxxx>, 613-592-2122 x2522
> "Any intelligent fool can make things bigger and more complex... It
> takes a touch of genius - and a lot of courage to move in the opposite
> direction." --Albert Einstein
>
> --
> Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux