diff options
Diffstat (limited to 'install/upgrade.php')
-rw-r--r-- | install/upgrade.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/install/upgrade.php b/install/upgrade.php index db0c913..c759df0 100644 --- a/install/upgrade.php +++ b/install/upgrade.php @@ -141,6 +141,27 @@ if (isset($_GET['upgrade'])) { } } + if (lower_version($_GET['upgrade'], '0.5.2')) { + try { + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."mail` ( + `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, + `contactId` smallint(5) unsigned NOT NULL, + `offerId` smallint(5) unsigned DEFAULT NULL, + `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `subject` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + KEY `contactId` (`contactId`), + KEY `offerId` (`offerId`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); + + $_pdo->query("ALTER TABLE `".Constants::db_prefix."mail` + ADD CONSTRAINT `mail_ibfk_1` FOREIGN KEY (`contactId`) REFERENCES `".Constants::db_prefix."contact` (`id`) ON UPDATE CASCADE, + ADD CONSTRAINT `mail_ibfk_2` FOREIGN KEY (`offerId`) REFERENCES `".Constants::db_prefix."offer` (`id`) ON UPDATE CASCADE;"); + } catch (PDOException $e) { + echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}<br/>" . $e->getTraceAsString(); + } + } + echo "<br/>All done."; } ?> |