I'm currently trying to determine how to apply mysql database patches via mercurial commit hooks. Basically, I have an incoming commit hook pointing to some script in my search path. This all works. My real question is how do keep a series of mysql alter table statements that can be applied every time I pull (incoming mercurial hook), that won't error when run again. For instance:
I add a new column to a table. So in my altertables.sql I add something like:
ALTER TABLE `thecompany_tbl` ADD `firstLogin` INT NOT NULL DEFAULT '1';
I run this the first time via the automated commit hook. Works fine. Next time I pull, it will try and run this again, and yield something like:
#1060 - Duplicate column name 'firstLogin'
Anyway around this? It would be great if I could just keep a file with all the alterations and then apply it every time I pull. Thanks for any advice!