-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdatabase.php
More file actions
56 lines (46 loc) · 1.53 KB
/
Copy pathdatabase.php
File metadata and controls
56 lines (46 loc) · 1.53 KB
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
$DATABASE_UNINSTALL = array(
"drop table if exists {$CFG->dbprefix}context_map"
);
$DATABASE_INSTALL = array(
array( "{$CFG->dbprefix}context_map",
"create table {$CFG->dbprefix}context_map (
context_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
lat FLOAT,
lng FLOAT,
color INTEGER,
email TINYINT,
name TINYINT,
first TINYINT,
updated_at DATETIME NOT NULL,
CONSTRAINT `{$CFG->dbprefix}context_map_ibfk_1`
FOREIGN KEY (`context_id`)
REFERENCES `{$CFG->dbprefix}lti_context` (`context_id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `{$CFG->dbprefix}context_map_ibfk_2`
FOREIGN KEY (`user_id`)
REFERENCES `{$CFG->dbprefix}lti_user` (`user_id`)
ON DELETE CASCADE ON UPDATE CASCADE,
UNIQUE(context_id, user_id)
) ENGINE = InnoDB DEFAULT CHARSET=utf8")
);
$DATABASE_UPGRADE = function($oldversion) {
global $CFG, $PDOX;
$table = "{$CFG->dbprefix}context_map";
$add_some_fields = array(
array('email', 'TINYINT'),
array('name', 'TINYINT'),
array('first', 'TINYINT'),
);
foreach ( $add_some_fields as $add_field ) {
$column = $add_field[0];
$type = $add_field[1];
if ( $PDOX->columnExists($column, $table) ) continue;
$sql= "ALTER TABLE {$table} ADD {$column} {$type}";
echo("Upgrading: ".$sql."<br/>\n");
error_log("Upgrading: ".$sql);
$q = $PDOX->queryReturnError($sql);
}
return 2014042000;
};