Re: Schema Upgrade Howto - Mailing list pgsql-general

From Thomas Guettler
Subject Re: Schema Upgrade Howto
Date
Msg-id 4909B8A7.7080709@tbz-pariv.de
Whole thread Raw
In response to Re: Schema Upgrade Howto  (David Fetter <david@fetter.org>)
Responses Re: Schema Upgrade Howto  (David Fetter <david@fetter.org>)
List pgsql-general
Hi,

I found a way to do it. One problem remains: The order of the columns
can't be changed.
Any change to make postgres support this in the future?

My way:

pg_dump -s prod  | strip-schema-dump.py - > prod.schema
pg_dump -s devel | strip-schema-dump.py - > devel.schema

strip-schema-dump.py removes some stuff which I don't care about (Owner, Comments, ...)

kdiff3 prod.schema devel.schema

You need to create an upgrade script by looking at the diff.
But it is not difficult:

-- update-YYYY-MM-DD.sql
begin;
alter table ... add column ...;
...
commit;

Execute on production:
cat update-YYYY-MM-DD.sql | psql

See http://www.djangosnippets.org/snippets/1160/


David Fetter schrieb:
> On Thu, Oct 30, 2008 at 10:54:46AM +0100, Thomas Guettler wrote:
>
>> Hi,
>>
>> is there a schema upgrade howto? I could not find much with google.
>>
>> There is a running DB and a development DB. The development DB
>> has some tables, columns and indexes added.
>>
>
> The only sure way to track such changes is by changing the
> databases--especially in development--only via scripts, all of which
> go into your source code management system.
>
>


--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


pgsql-general by date:

Previous
From: "Roberts, Jon"
Date:
Subject: Re: Piping CSV data to psql when executing COPY .. FROM STDIN (Solved)
Next
From: Teodor Sigaev
Date:
Subject: Re: Weird problem concerning tsearch functions built into postgres 8.3, assistance requested