Re: Mapping/DB Migration tool - Mailing list pgsql-general

From Reece Hart
Subject Re: Mapping/DB Migration tool
Date
Msg-id 1153864175.30183.78.camel@tallac.gene.com
Whole thread Raw
In response to Mapping/DB Migration tool  ("MC Moisei" <mcmoisei@hotmail.com>)
Responses Re: Mapping/DB Migration tool  ("MC Moisei" <mcmoisei@hotmail.com>)
List pgsql-general
On Tue, 2006-07-25 at 13:59 -0500, MC Moisei wrote:
I'm looking to migrate psql db1 to a psql db2 that has a different structure
even though 70% would be the same.

Depending on how much the structure changes (as opposed to more trivial things like column names), you might consider whether you could actually use the database itself to do this.

For some kinds of changes, and especially those that make destructive in-place changes that might require debugging, I've written views which generate the SQL statements to execute. I then do something like:

$ psql -Atc 'select sql from sql_changes'  | psql -Xa

This works particularly well when the changes can be computed in some way from the database, such as creating indexes for unindexed PKs (postgresql doesn't require indexes on PKs).

You'd probably want to do this by making copies of the original database as a template ('create database db2 template db1') or createdb -T .

-Reece

-- 
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

pgsql-general by date:

Previous
From: Michael Meskes
Date:
Subject: Re: ECPG usage
Next
From: "MC Moisei"
Date:
Subject: Re: Mapping/DB Migration tool