pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_version_history
2+ messages / 1 participants
[nested] [flat]

* pg_version_history
@ 2005-04-26 02:04 Ezequiel Tolnay <mail@etolnay.com.ar>
  2005-05-02 04:52 ` Re: pg_version_history Ezequiel Tolnay <mail@etolnay.com.ar>
  0 siblings, 1 reply; 2+ messages in thread

From: Ezequiel Tolnay @ 2005-04-26 02:04 UTC (permalink / raw)
  To: pgsql-admin

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?

Thanks

Ezequiel Tolnay
etolnay@gbtech.com.au



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: pg_version_history
  2005-04-26 02:04 pg_version_history Ezequiel Tolnay <mail@etolnay.com.ar>
@ 2005-05-02 04:52 ` Ezequiel Tolnay <mail@etolnay.com.ar>
  0 siblings, 0 replies; 2+ messages in thread

From: Ezequiel Tolnay @ 2005-05-02 04:52 UTC (permalink / raw)
  To: pgsql-admin

> 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-05-02 04:52 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-04-26 02:04 pg_version_history Ezequiel Tolnay <mail@etolnay.com.ar>
2005-05-02 04:52 ` Ezequiel Tolnay <mail@etolnay.com.ar>

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