From: Ezequiel Tolnay <mail@etolnay.com.ar>
To: pgsql-admin@postgresql.org
Subject: Re: pg_version_history
Date: Mon, 02 May 2005 14:52:49 +1000
Message-ID: <d54bla$vfg$1@news.hub.org> (raw)
In-Reply-To: <d4k7j1$lg1$1@news.hub.org>
References: <d4k7j1$lg1$1@news.hub.org>
> 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=<db-name>
USR=<db-admin-user>
PWD=<db-admin-pwd>
DUMP=<pg-bin-dir>/pg_dump
SCRIPT_PATH=<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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: mail@etolnay.com.ar
Subject: Re: pg_version_history
In-Reply-To: <d54bla$vfg$1@news.hub.org>
References: <d4k7j1$lg1$1@news.hub.org> <d54bla$vfg$1@news.hub.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox