forked from mythril/skyhook
-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.php
56 lines (46 loc) · 1.12 KB
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require_once __DIR__ . '/includes/autoload.php';
$db = new DB();
$stmt = $db->query("SHOW COLUMNS FROM `purchases`;");
$addEmailToNotify = true;
$addNTXID = true;
$fixPrecision = true;
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
if ($row['Field'] === 'email_to_notify') {
$addEmailToNotify = false;
}
if ($row['Field'] === 'bitcoin_amount') {
if (strpos($row['Type'], '16') !== false) {
$fixPrecision = false;
}
}
if ($row['Field'] === 'ntxid') {
$addNTXID = false;
}
}
if ($addEmailToNotify) {
$db->query('
ALTER TABLE `purchases`
ADD COLUMN
email_to_notify TEXT NULL DEFAULT NULL AFTER notice;
');
echo "Column 'email_to_notify' added.\n";
}
if ($addNTXID) {
$db->query('
ALTER TABLE `purchases`
ADD COLUMN
`ntxid` VARCHAR(64) NULL DEFAULT NULL AFTER txid;
');
echo "Column 'ntxid' added.\n";
}
if ($fixPrecision) {
$db->query('
ALTER TABLE `purchases`
MODIFY COLUMN
bitcoin_amount DECIMAL(16, 8) NOT NULL DEFAULT 0.0000
');
echo "Column 'bitcoin_amount' fixed.\n";
}
$stmt = $db->query(file_get_contents(__DIR__ . '/database/jobs.sql'));
echo "update finished\n";