X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2E10C5321C for ; Mon, 2 May 2005 02:11:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32354-08 for ; Mon, 2 May 2005 05:10:56 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 81FD6531C7 for ; Mon, 2 May 2005 02:10:56 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.13.1/8.13.1) with ESMTP id j425Ar9B034642 for ; Mon, 2 May 2005 05:10:53 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.13.1/8.13.1/Submit) id j424ptkD032241 for pgsql-admin@postgresql.org; Mon, 2 May 2005 04:51:55 GMT (envelope-from news) From: Ezequiel Tolnay X-Newsgroups: pgsql.admin Subject: Re: pg_version_history Date: Mon, 02 May 2005 14:52:49 +1000 Organization: Hub.Org Networking Services Lines: 49 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050319 X-Accept-Language: en-au, en-gb, en-us, en, es-ar, es-es In-Reply-To: To: pgsql-admin@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/76 X-Sequence-Number: 17505 > I found a table pg_version_history in the public schema (which we don't > use). Does anyone know where this table comes from and what is it for? > > Also I'd like to implement a code versioning for the functions. Is there > a package or a software to do this kind of things, so we can recover > from it a function in case it is deleted or overwritten with an old > version? It is a pretty dumb thing to reply to myself, but perhaps I can share with the newsgroup readers the solution I found for this issue. Although not as convenient as I was looking for, it does the job. It requires the use of a cvs server, and some skills to set-up a new folder in it. Windows users would require to use cygwin for the script, with cron and cvs. Create the following script somewhere: #!/bin/bash DB= USR= PWD= DUMP=/pg_dump SCRIPT_PATH= SCRIPT=${DB}-schema.sql pushd $SCRIPT_PATH echo $PWD | $DUMP -sC -U $USR $DB > $SCRIPT 2> /dev/null && \ cvs commit -m "" $SCRIPT > /dev/null popd Replace the variable values with whatever you prefer and run the command. It should fail to upload the script to the cvs server. Now login to the cvs and create a new repository for this folder and add the schema file generated. Finally set-up a cron job to call the script once every hour, or as often as it suits you. The script will keep track of the changes in the schema file maintained by the cvs. Not very efficient, since there will be no references as to what has changed on each version, or who made the changes, but still useful to recover accidentally deleted/modified functions or views and so forth. I hope this is useful to anyone. Regards, Ezequiel Tolnay etolnay@gbtech.com.au