diff options
author | Camil Staps | 2016-07-31 09:40:25 +0200 |
---|---|---|
committer | Camil Staps | 2016-07-31 09:40:25 +0200 |
commit | 1ec8d12a7b125d41ecb723c5d83f2afef95408e9 (patch) | |
tree | 4d103ccbab48d2217e1ae13d37c229e4060e9184 /install/upgrade.php | |
parent | Give new files a key (diff) |
0.5.2 emails
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."; } ?> |