From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1FqwX3-00042V-O3 for garchives@archives.gentoo.org; Thu, 15 Jun 2006 18:25:30 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.7/8.13.6) with SMTP id k5FINB8a019298; Thu, 15 Jun 2006 18:23:11 GMT Received: from web53208.mail.yahoo.com (web53208.mail.yahoo.com [206.190.49.78]) by robin.gentoo.org (8.13.7/8.13.6) with SMTP id k5FIFfGa011049 for ; Thu, 15 Jun 2006 18:15:41 GMT Received: (qmail 44944 invoked by uid 60001); 15 Jun 2006 18:15:37 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=5tgNmSb3NAkx7Y5ohsjn3iiH96r+Xhm/6WkPpgjLMbSVgYtJOxhsN1NjlOn2QcmDCX5i791jLVFQvNZH11sQwJqSBoA5c1J7IG/WAnyRkD4DdlrHMnYbC52HlQEB4An/4NAe1ssGfHrUqJVBzW75pfzy/eWm9lM3aK5lspVTVRE= ; Message-ID: <20060615181537.44942.qmail@web53208.mail.yahoo.com> Received: from [70.90.161.73] by web53208.mail.yahoo.com via HTTP; Thu, 15 Jun 2006 11:15:37 PDT Date: Thu, 15 Jun 2006 11:15:37 -0700 (PDT) From: Benjamin Blazke Subject: [gentoo-user] [OT] Looking for a tool to produce 'reverse' SQL To: gentoo-user@lists.gentoo.org Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archives-Salt: 6580272b-21cd-43cd-a5d1-c0f771659ab4 X-Archives-Hash: 0ea83128de938f8bd19f1cf7fef3dc59 Hi, I'm looking for a tool that given an existing (base) database schema and an 'update patch' DDL .sql script on input would produce a 'reverse' script that could be used to undo the changes done by the patch. For example: base.sql: CREATE TABLE xxx (...); patch.sql: CREATE TABLE yyy (...); ALTER TABLE xxx ADD COLUMN aaa ...; ALTER TABLE xxx CHANGE column bbb ... reverse.sql: DROP TABLE yyy; ALTER TABLE xxx DROP column aaa; ALTER TABLE xxx CHANGE column bbb The purpose of this exercise is to have a production database (MySQL) server that needs to update its schema once in a while to reflect the changes in the related application without the need to recreate the schema from scratch (and possibly losing data). The reverse.sql script could be later used to rollback the schema changes at any time, even rollback multiple patches. How do people generally solve this? I'm sure this must be a fairly common problem. Thanks. Ben __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- gentoo-user@gentoo.org mailing list