Simple schema diff script in Perl

Started by Hans C. Pooover 15 years ago5 messagesgeneral
Jump to latest
#1Hans C. Poo
hans@welinux.cl

Hi,

I was looking for a simple diff program to compare two schemas, i found two scripts out there but one compared everything and was too much for me, the other was a ruby script i wasn't able to run, so i wrote a little perl script that do the trick:

http://www.welinux.cl/hans/dbdiff.pl

Actually just compare tables and fields, for my current requirements is ok, i plan to add the sequences, but no more.

Actually it uses Pg as default perl driver, but any installed perl DBI driver should work.

The final comparison is done with vimdiff command of the vim suite, so it requires it to be installed. If there is some better (and simple) tool please let me know.

Bye
Hans

--
Hans Poo, WeLinux S.A. http://www.welinux.cl
Oficina: +56-2-372.9770, Celular: 09-319.93.05
Bombero Ossa # 1010, Of: 526, Santiago

#2Randal L. Schwartz
merlyn@stonehenge.com
In reply to: Hans C. Poo (#1)
Re: Simple schema diff script in Perl

"hans" == hans <hans@welinux.cl> writes:

hans> Actually just compare tables and fields, for my current
hans> requirements is ok, i plan to add the sequences, but no more.

I believe SQLFairy (aka SQL::Translator) can canonicalize schemas, and
even give DDL to turn one schema into another.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/&gt;
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

#3Hans C. Poo
hans@welinux.cl
In reply to: Randal L. Schwartz (#2)
Re: Simple schema diff script in Perl

Hi,

Thanks for the quick response, i installed sqlfaiyr and guess that sqlt-diff is what i'm loogin for, but i can't guess how to use it, do you have any call samples, i found this:

sqlt-diff --to MySQL Schema1=MySQL Schema2=MySQL > SchemaUpdate.mysql.sql

i can't guess where is the database name or user to use, if it work with dumps i need to give the dump files and the database type...

Hans

----- "Randal L. Schwartz" <merlyn@stonehenge.com> escribió:

"hans" == hans <hans@welinux.cl> writes:

hans> Actually just compare tables and fields, for my current
hans> requirements is ok, i plan to add the sequences, but no more.

I believe SQLFairy (aka SQL::Translator) can canonicalize schemas,
and
even give DDL to turn one schema into another.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/&gt;
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside
discussion

--
Hans Poo, WeLinux S.A. http://www.welinux.cl
Oficina: +56-2-372.9770, Celular: 09-319.93.05
Bombero Ossa # 1010, Of: 526, Santiago

#4Florian Weimer
fweimer@bfk.de
In reply to: Hans C. Poo (#3)
Re: Simple schema diff script in Perl

sqlt-diff --to MySQL Schema1=MySQL Schema2=MySQL > SchemaUpdate.mysql.sql

i can't guess where is the database name or user to use, if it work
with dumps i need to give the dump files and the database type...

My version says:

| Currently (v0.0900), only MySQL is supported by this code.

I don't know if there is a newer version.

I can see that such a tool could be useful.

--
Florian Weimer <fweimer@bfk.de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99

#5Sualeh Fatehi
sualeh.fatehi@gmail.com
In reply to: Hans C. Poo (#1)
Re: Simple schema diff script in Perl

If you are still looking for a program to compare databases, take a
look at SchemaCrawler - http://schemacrawler.sourceforge.net

Sualeh.