aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--classes/constants.class.php4
-rw-r--r--install/upgrade.php29
3 files changed, 24 insertions, 12 deletions
diff --git a/README.md b/README.md
index c164343..587ef62 100644
--- a/README.md
+++ b/README.md
@@ -128,7 +128,8 @@ When you delete an invoice file, it's not actually deleted. Instead, it's placed
### 0.2 (Feb 10, 2015)
-Sort clients, contacts and assignments.
+0.2.1 Sort clients, contacts and assignments.
+0.2.2 Allow deletion of offers (foreign key constraint set to cascade rather than restrict).
### 0.1 (Feb 6, 2015)
diff --git a/classes/constants.class.php b/classes/constants.class.php
index bb9da03..ad63521 100644
--- a/classes/constants.class.php
+++ b/classes/constants.class.php
@@ -70,5 +70,5 @@ class constants {
const fa_valuta = 'eur';
/** @const version Version of BusinessAdmin. Don't change this yourself! */
- const version = '0.2.1';
-} \ No newline at end of file
+ const version = '0.2.2';
+}
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()}<br/>" . $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()}<br/>" . $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()}<br/>" . $e->getTraceAsString();
+ }
+
+ }
+
echo "<br/>All done.";
}
?>
@@ -53,4 +64,4 @@ if (isset($_GET['upgrade'])) {
<form method="GET">
<input type="text" name="upgrade" placeholder="Old version"/>
<input type="submit" value="Upgrade"/>
-</form> \ No newline at end of file
+</form>