Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 41D60475F07 for ; Thu, 22 Aug 2002 15:43:03 -0400 (EDT) Received: from briar.mmrd.com (unknown [208.255.226.182]) by postgresql.org (Postfix) with ESMTP id 4B004475EC3 for ; Thu, 22 Aug 2002 15:43:02 -0400 (EDT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by briar.mmrd.com (8.11.2/8.11.2) with ESMTP id g7MKfQF01349; Thu, 22 Aug 2002 16:41:26 -0400 Received: from [172.25.1.55] ([172.25.1.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id g7MJh2x15012; Thu, 22 Aug 2002 15:43:03 -0400 Subject: Re: mysqldiff-like utility for PG? From: Robert Treat To: Kevin Brannen Cc: pgsql-admin@postgresql.org In-Reply-To: <3D6528A7.1060709@nurseamerica.net> References: <5580cd6f.0208151843.52ff6467@posting.google.com> <20020821172224.5c576d36.Tim.Ellis@gamet.com> <3D6528A7.1060709@nurseamerica.net> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 22 Aug 2002 15:41:59 -0400 Message-Id: <1030045319.27266.35.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/266 X-Sequence-Number: 5380 On Thu, 2002-08-22 at 14:08, Kevin Brannen wrote: > I think you're missing the point of his request. Upgrading applications > (or anything binary) is trivial compared to upgrading a working > database, IMHO. (but maybe you just picked a bad analogy :-) > > > I don't see how you can keep a production DB running in any other way. > If you can, please let us know! But once a schema is being used in > production, and has a data in it, you can't just drop it and stuff a new > schema in; it needs to be transformed. Assuming you have maintenance windows for when you would be upgrading your database, there's no reason you have to rule out a full drop/reload of the database system. > And that's what the diff tool > does, helps to transform. > > So he's not alone in his problem. Hope that helps you to understand > what he was asking for. > Either method of upgrading is definitely valid under the right circumstances, but I would second any notion to keep entire schema versions in CVS and not just the "upgrades". > Hmmm, I wonder if I could write this... Ignoring constraint changes, it > doesn't sound that hard. If I do this, I'll post it to the news group. > > Kevin > I am sure there are open source projects doing something similar to this now (perhaps even the mentioned mysql utility?) that could give you a jump start. If your doing this for 7.2.2, watch out for dropping columns.. Robert Treat > > Tim Ellis wrote: > >>"mysqldiff is a Perl script which compares the data structures (i.e. > >>table definitions) of two MySQL databases, and returns the differences > >>as a sequence of MySQL commands suitable for piping into mysql which > >>will transform the structure of the first database to be identical to > >>that of the second (c.f. diff and patch). Database structures can be > >>compared whether they are files containing table definitions or > >>existing databases, local or remote. " > >> > >>It would make our lives 1000x easier if such a tool existed. As it > >>stands now, the process of updating the DB involves manually writing a > >>series of alter statements, which is a huge pain. I can't be the only > >>one with this problem! > > > ... > > > > By the same token, database schemas should be created by some source code > > (ie: ERDs) and then 'compiled' into the form you use. Revisions of the > > ERDs should be stored in revision control (ie: CVS). > > > > Your problem may have a solution (a postgresdiff might exist) but if you > > find it, I urge you not to use it. Instead, keep ERDs for the old version > > and new version, and compile them to the database. > > > > Disallow the use of DDL in your database unless it was generated by the > > tool that stores your ERD. Give developers that need to change the table > > definitions access to your ERD tool. Dia is such a tool that gives you > > these options. > > > > If you cannot do this, your databases will drive you mad. > >