From 4f84eb2b09bf51eabdc29b5eeec101e0260b1cb7 Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Thu, 28 Jul 2016 09:37:48 +0200
Subject: Braintree integration: first version
---
install/upgrade.php | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
(limited to 'install/upgrade.php')
diff --git a/install/upgrade.php b/install/upgrade.php
index aea97ce..8ead230 100644
--- a/install/upgrade.php
+++ b/install/upgrade.php
@@ -97,9 +97,8 @@ if (isset($_GET['upgrade'])) {
$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);
+ $stmt = $_pdo->prepare("INSERT IGNORE INTO `".Constants::db_prefix."payment` (`offerId`,`date`) VALUES (?,?)");
+ $stmt->execute($offer['id'], $offer['payment_received']);
}
$_pdo->query("ALTER TABLE `".Constants::db_prefix."offer` DROP `payment_received`;");
@@ -108,6 +107,19 @@ if (isset($_GET['upgrade'])) {
}
}
+ if (lower_version($_GET['upgrade'], '0.5')) {
+ try {
+ $_pdo->query("ALTER TABLE `".Constants::db_prefix."offer`
+ ADD `payment_key` VARCHAR(63) DEFAULT NULL;");
+ $_pdo->query("ALTER TABLE `".Constants::db_prefix."payment`
+ ADD `braintree_id` VARCHAR(36) DEFAULT NULL,
+ ADD `braintree_status` VARCHAR (63) NULL DEFAULT NULL;");
+ $_pdo->query("CREATE UNIQUE INDEX `payment_uniq_1` ON `".Constants::db_prefix."payment` (`offerId`);");
+ } 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