Forum OpenACS Q&A: Re: PG 7.2->7.3 upgrade gotcha?

Collapse
Posted by Richard Hamilton on
OK, I had a second site to upgrade so I decided to re-visit the database upgrade script that Jun very kindly posted and, since I am in the process of trying to learn perl, work it into a slightly more general solution.

I have re-written it to work a different way around. Instead of grepping the entire OpenACS file tree every time it finds a long function name, the script now greps the files once only and extracts all function and view definitions - storing them in a hash.

It then runs through the pg_dump file, looking for all lines starting with 'CREATE', 'DROP' and '--Name : "', and substitutes the correct name in place of the truncated name.

This runs a great deal faster and catches every truncated name, including those in the CREATE VIEW statements that were previously missed, and those where the truncated function names are referenced in definitions of other dependent views (which has been noted by someone in a different thread). In short this SHOULD render the database upgrade trivial from here on in - I hope 😊

Usage is identical to Jun's original script and every substitution is displayed as before though in a slightly different format. I suggest piping output to a file to study before you try to restore the dump.

I hope that this will help to speed things up for people and that it will prove robust accross installations with a variety of different packages installed.

I am new to perl so if anyone has any feedback for me I'd welcome it.

I tried to upload it here but the ACS chokes on the perl file handle because it thinks that it is a html tag. So if anyone wants the script (to use or to add to the CVS) just email me.

Regards
Richard