Re: pg_version_history

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux