Re: db schema diff

From: <btober(at)computer(dot)org>
To: <igor(at)carcass(dot)ath(dot)cx>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: db schema diff
Date: 2004-04-12 19:38:07
Message-ID: 64719.216.238.112.88.1081798687.squirrel@$HOSTNAME
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Suppose I have "pg_dump -s" of two pg installs, one is "dev", another
> is "production". Their schemas don't differ too much, and I want to
> get a "diff -u"-like schema diff so I can quickly add missing/remove
> old
> tables/sequences/etc to one or another (manually). Is there some quick
> tool for doing this ?
>
> There was a thread about it sometime in aug, 2002, but it ended without
> producing anything useful.

This is the closest I get, but it is only marginally useful:

--File: pg_compare --------------------------------------
#!/bin/bash
# Script to dump a PostgreSQL database schema for two databases
# and compare them.
# Author: Berend M. Tober <btober(at)computer dot org>
# Date: August 25, 2003

PG_DUMP=/usr/bin/pg_dump
DIFF=/usr/bin/diff
GREP=/bin/grep
CAT=/bin/cat

-- 5434 is the port on which DEV runs
-- 5433 is the port on which QAT runs

${PG_DUMP} -s -p 5432 mydb|${GREP} -v '^--'|${CAT} -s >5432.sql
${PG_DUMP} -s -p 5433 mydb|${GREP} -v '^--'|${CAT} -s >5433.sql
${PG_DUMP} -s -p 5434 mydb|${GREP} -v '^--'|${CAT} -s >5434.sql

${DIFF} 5432.sql 5433.sql > 5432-5433.diff
${DIFF} 5433.sql 5434.sql > 5433-5434.diff

~Berend Tober

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Igor Shevchenko 2004-04-12 20:21:29 Re: db schema diff
Previous Message Clodoaldo Pinto Neto 2004-04-12 19:17:01 Re: COPY TO order