I have a PHP app that gets updated frequently and deployed to our users. The problem is that sometimes an update adds new tables or columns which the user's local table does not have.
How can one dynamically create a table it is missing, or add missing columns to an existing table? I'm looking to make this process semi-automated, since tables and columns will always change in the future.
Here's my code to create a table
CREATE TABLE `comments` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
`content_id` int(11) DEFAULT '0',
`body` text,
`name` text,
`creation_ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`delta` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`comment_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;