I have exported a database (structure only) from phpMyAdmin which I want to use as the bases for a script that can update a previous version of the same database structure and add columns and tables if they don't exist.
For example, if the CREATE TABLE statement looks like this:
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(52) NOT NULL,
`password` varchar(40) NOT NULL,
`dev` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21;
How can I adjust this so if a field in the table does not exist it will be created even if the table already exists in the database.
The aim of this script is to allow updating of already existing databases, adding columns that may be missing, but it should not remove any tables or fields.