From 4286a26a23944e5cbc4700443a0a3f998d73f2e1 Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Mon, 7 Dec 2015 23:50:26 +0000
Subject: Fix deleting offers
---
install/upgrade.php | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
(limited to 'install')
diff --git a/install/upgrade.php b/install/upgrade.php
index d2252cb..55b4316 100644
--- a/install/upgrade.php
+++ b/install/upgrade.php
@@ -36,15 +36,26 @@ function lower_version($that, $new) {
return false;
}
-if (isset($_GET['upgrade']) && lower_version($_GET['upgrade'], '0.1')) {
- try {
- $_pdo->query("ALTER TABLE `assignment` CHANGE `hours` `hours` FLOAT UNSIGNED NOT NULL");
- } catch (PDOException $e) {
- echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}
" . $e->getTraceAsString();
- }
-}
-
if (isset($_GET['upgrade'])) {
+
+ if (lower_version($_GET['upgrade'], '0.1')) {
+ try {
+ $_pdo->query("ALTER TABLE `".constants::db_prefix."assignment` CHANGE `hours` `hours` FLOAT UNSIGNED NOT NULL");
+ } catch (PDOException $e) {
+ echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}
" . $e->getTraceAsString();
+ }
+ }
+
+ if (lower_version($_GET['upgrade'], '0.2.2')) {
+ try {
+ $_pdo->query("ALTER TABLE `".constants::db_prefix."assignment` DROP FOREIGN KEY `assignment_ibfk_1`");
+ $_pdo->query("ALTER TABLE `".constants::db_prefix."assignment` ADD CONSTRAINT `assignment_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".constants::db_prefix."offer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE");
+ } catch (PDOException $e) {
+ echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}
" . $e->getTraceAsString();
+ }
+
+ }
+
echo "
All done.";
}
?>
@@ -53,4 +64,4 @@ if (isset($_GET['upgrade'])) {