aboutsummaryrefslogtreecommitdiff
path: root/install/upgrade.php
diff options
context:
space:
mode:
Diffstat (limited to 'install/upgrade.php')
-rw-r--r--install/upgrade.php18
1 files changed, 15 insertions, 3 deletions
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()}<br/>" . $e->getTraceAsString();
+ }
+ }
+
echo "<br/>All done.";
}
?>