nabeel shahzad

phpVMS 1.1.400 released, lessons learned

with one comment

I put out the update for 1.1.400 (version bump, went from 1.0 to 1.1 because of “major” features), then the 400 being the revision number from SVN. So far no problems, my main concern were the tons of database changes, including the removal of foreign keys, which made me a bit nervous, since I guess different versions react differently.

Instead of doing scratch installs, and then doing an update (time consuming), I wrote a quick SQL file, and another bash script which would automatically insert the older 1.0 database (basically running the install.sql), and then run the update.sql, and report any errors which are thrown:

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# MySQL Installer and Update Check
# Nabeel Shahzad <http://www.nsslive.net>
DBUSER=""
DBPASS=""
DBNAME=""
DBSERVER=""
INSTALLFILE='install.sql'
UPDATEFILE='update.sql'
mysql -u uname dbname -e "show tables" | grep -v Tables_in | grep -v "+" | \
gawk '{print "drop table " $1 ";"}' | mysql -u uname dbname
mysql -u $DBUSER -p $DBPASS -h $DBSERVER $DBNAME < $INSTALLFILE
clear
mysql -u $DBUSER -p $DBPASS -h $DBSERVER $DBNAME < $UPDATEFILE

The line to drop all the tables was from this page here (thanks!). My install.sql can also include the SQL inserts for default values (I will post the code for my installer soon, since it’ll just read any .sql file), but what I will do is create a backup of an existing DB with all my data, and run the update against that using this script.

Pretty basic, but really handy to just viewing errors.

Written by Nabeel

November 18th, 2008 at 9:59 am

Posted in General,php,phpVMS

  • http://www.eks-tury.ru RYErnest

    Nice post u have here :D Added to my RSS reader