forked from csev/py4e
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.php
More file actions
58 lines (42 loc) · 1.49 KB
/
database.php
File metadata and controls
58 lines (42 loc) · 1.49 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
57
<?php
// To allow this to be called directly or from admin/upgrade.php
if ( !isset($PDOX) ) {
require_once "../config.php";
$CURRENT_FILE = __FILE__;
require $CFG->dirroot."/admin/migrate-setup.php";
}
// Dropping tables
$DATABASE_UNINSTALL = array(
"drop table if exists {$CFG->dbprefix}pythonauto_log",
);
// Creating tables
$DATABASE_INSTALL = array(
array( "{$CFG->dbprefix}pythonauto_log",
"create table {$CFG->dbprefix}pythonauto_log (
log_id INTEGER NOT NULL KEY AUTO_INCREMENT,
link_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
exercise VARCHAR(128) NULL,
code TEXT NULL,
grade FLOAT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL,
CONSTRAINT `{$CFG->dbprefix}pythonauto_log_ibfk_1`
FOREIGN KEY (`link_id`)
REFERENCES `{$CFG->dbprefix}lti_link` (`link_id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `{$CFG->dbprefix}pythonauto_loghread_ibfk_2`
FOREIGN KEY (`user_id`)
REFERENCES `{$CFG->dbprefix}lti_user` (`user_id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8"),
);
// Database upgrade
$DATABASE_UPGRADE = function($oldversion) {
global $CFG, $PDOX;
return 202001010815;
}; // Don't forget the semicolon on anonymous functions :)
// Do the actual migration if we are not in admin/upgrade.php
if ( isset($CURRENT_FILE) ) {
include $CFG->dirroot."/admin/migrate-run.php";
}