From 38736c4b8fd1e9da5f3e6d0c6c088db90c4186d2 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 1 Aug 2016 17:21:49 +0200 Subject: Fix payment table --- install/upgrade.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'install/upgrade.php') diff --git a/install/upgrade.php b/install/upgrade.php index 0ebff57..8c97172 100644 --- a/install/upgrade.php +++ b/install/upgrade.php @@ -94,9 +94,13 @@ if (isset($_GET['upgrade'])) { `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `offerId` smallint(5) unsigned NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE KEY `offerId` (`offerId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."payment` + ADD CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".Constants::db_prefix."offer` (`id`);"); + $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) { -- cgit v1.2.3