Re: Database schema diff - Mailing list pgsql-hackers

From Torello Querci
Subject Re: Database schema diff
Date
Msg-id CA+igE6QkVFtJaxvnn=NC=+PJ+e4MXabq=0+OJpEG0Li5i2Pqgg@mail.gmail.com
Whole thread Raw
In response to Re: Database schema diff  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
Responses Re: Database schema diff  (Michal Novotny <michal.novotny@trustport.com>)
List pgsql-hackers
Few years ago I developed a tool called fsgateway (https://github.com/mk8/fsgateway) that show metadata (table, index, sequences, view) as normal files using fuse.
In this way to yout can get differences between running db instance using diff, meld or what do you prefear.

Unfortunally at the moment not all you need is supported, yet.

Best regards

P.S. I think that this is the wrong list for questione like this one.

On Wed, Oct 14, 2015 at 10:26 AM, Shulgin, Oleksandr <oleksandr.shulgin@zalando.de> wrote:
On Tue, Oct 13, 2015 at 5:48 PM, Michal Novotny <michal.novotny@trustport.com> wrote:
Hi guys,

I would like to ask you whether is there any tool to be able to compare
database schemas ideally no matter what the column order is or to dump
database table with ascending order of all database columns.

For example, if I have table (called table) in schema A and in schema B
(the time difference between is 1 week) and I would like to verify the
column names/types matches but the order is different, i.e.:

Schema A (2015-10-01) |  Schema B (2015-10-07)
                      |
id int                |  id int
name varchar(64)      |  name varchar(64)
text text             |  description text
description text      |  text text

Is there any tool to compare and (even in case above) return that both
tables match? Something like pgdiff or something?

This should work for all schemas, tables, functions, triggers and all
the schema components?

I've used pg_dump --split for this purpose a number of times (it requires patching pg_dump[1]).

The idea is to produce the two database's schema dumps split into individual files per database object, then run diff -r against the schema folders.  This worked really well for my purposes.

This will however report difference in columns order, but I'm not really sure why would you like to ignore that.

--
Alex

pgsql-hackers by date:

Previous
From: Beena Emerson
Date:
Subject: Re: Support for N synchronous standby servers - take 2
Next
From: Alexander Korotkov
Date:
Subject: Re: Use pg_rewind when target timeline was switched