From c67d248601031a0245dfe64b609fa6623868014b Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Wed, 27 Jul 2016 14:52:49 +0200
Subject: v0.4.2 moved payment_received to separate table/class payment(s)
---
install/upgrade.php | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
(limited to 'install/upgrade.php')
diff --git a/install/upgrade.php b/install/upgrade.php
index e145ba7..78f5dff 100644
--- a/install/upgrade.php
+++ b/install/upgrade.php
@@ -86,6 +86,28 @@ if (isset($_GET['upgrade'])) {
}
}
+ if (lower_version($_GET['upgrade'], '0.4.2')) {
+ try {
+ $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."payment` (
+ `id` smallint(5) unsigned NOT NULL,
+ `offerId` smallint(5) unsigned NOT NULL,
+ `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
+
+ $offers = $_pdo->query("SELECT `id`,`payment_received` FROM `".constants::db_prefix."offer` WHERE `payment_received` IS NOT NULL");
+ $offers = $offers->fetchAll(PDO::FETCH_ASSOC);
+ foreach ($offers as $offer) {
+ $received = $offer['payment_received'];
+ $offer = new offer($_pdo, $offer['id']);
+ $offer->createPayment($received);
+ }
+
+ $_pdo->query("ALTER TABLE `".constants::db_prefix."offer` DROP `payment_received`;");
+ } catch (PDOException $e) {
+ echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}
" . $e->getTraceAsString();
+ }
+ }
+
echo "
All done.";
}
?>
--
cgit v1.2.3