Skip to content

Commit

Permalink
Upgrade the DB for blob_blob
Browse files Browse the repository at this point in the history
This is for issue #20 in tsugi-php
  • Loading branch information
csev committed Feb 9, 2018
1 parent 8a22525 commit 56e0369
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 13 deletions.
36 changes: 34 additions & 2 deletions admin/blob/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
file_sha256 CHAR(64) NOT NULL,
context_id INTEGER NULL,
link_id INTEGER NULL,
file_name VARCHAR(2048),
deleted TINYINT(1),
contenttype VARCHAR(256) NULL,
path VARCHAR(2048) NULL,
content LONGBLOB NULL,
blob_id INTEGER,
json TEXT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand All @@ -27,10 +29,29 @@
REFERENCES `{$CFG->dbprefix}lti_context` (`context_id`)
ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8"),
array( "{$CFG->dbprefix}blob_blob",
"create table {$CFG->dbprefix}blob_blob (
blob_id INTEGER NOT NULL AUTO_INCREMENT,
blob_sha256 CHAR(64) NOT NULL,
deleted TINYINT(1),
content LONGBLOB NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
accessed_at TIMESTAMP NOT NULL DEFAULT '1970-01-02 00:00:00',
PRIMARY KEY(blob_id),
UNIQUE(blob_sha256)
) ENGINE = InnoDB DEFAULT CHARSET=utf8")
);

$DATABASE_UNINSTALL = "drop table if exists {$CFG->dbprefix}blob_file";
$DATABASE_UNINSTALL = array(
"drop table if exists {$CFG->dbprefix}blob_file",
"drop table if exists {$CFG->dbprefix}blob_blob"
);

// No upgrades yet
$DATABASE_UPGRADE = function($oldversion) {
Expand Down Expand Up @@ -58,7 +79,18 @@
$q = $PDOX->queryDie($sql);
}

return 201710151700;
if ( $oldversion < 201802091240 ) {
$sql= "ALTER TABLE {$CFG->dbprefix}blob_file ADD link_id INTEGER NULL";
echo("Upgrading: ".$sql."<br/>\n");
error_log("Upgrading: ".$sql);
$q = $PDOX->queryDie($sql);
$sql= "ALTER TABLE {$CFG->dbprefix}blob_file ADD blob_id INTEGER NULL";
echo("Upgrading: ".$sql."<br/>\n");
error_log("Upgrading: ".$sql);
$q = $PDOX->queryDie($sql);
}

return 201802091240;

};

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"tsugi/lib": "dev-master#78149d49837ea4ccaba1df5f9a2f8d780fbbedd9",
"tsugi/lib": "dev-master#66e7af00d81f27d4f281d01e6aa671522d3e4290",
"twig/twig": "v1.33.2",
"silex/silex": "v2.0.4",
"symfony/translation": "v3.2.7",
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1563,12 +1563,12 @@
"source": {
"type": "git",
"url": "https://github.com/tsugiproject/tsugi-php.git",
"reference": "78149d49837ea4ccaba1df5f9a2f8d780fbbedd9"
"reference": "66e7af00d81f27d4f281d01e6aa671522d3e4290"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tsugiproject/tsugi-php/zipball/78149d49837ea4ccaba1df5f9a2f8d780fbbedd9",
"reference": "78149d49837ea4ccaba1df5f9a2f8d780fbbedd9",
"url": "https://api.github.com/repos/tsugiproject/tsugi-php/zipball/66e7af00d81f27d4f281d01e6aa671522d3e4290",
"reference": "66e7af00d81f27d4f281d01e6aa671522d3e4290",
"shasum": ""
},
"require": {
Expand Down
3 changes: 2 additions & 1 deletion vendor/tsugi/lib/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"symfony/translation": "v3.2.7"
},
"require-dev": {
"phpunit/phpunit": "4.8.21"
"phpunit/phpunit": "5.*",
"phpunit/php-timer": ">=1.0.6"
}
}
2 changes: 1 addition & 1 deletion vendor/tsugi/lib/include/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// upgrade checking - don't change this unless you want to trigger
// database upgrade messages it should be the max of all versions in
// all database.php files.
$CFG->dbversion = 201801271430;
$CFG->dbversion = 201802091240;

// Just turn this off to avoid security holes due to XML parsing
if ( function_exists ( 'libxml_disable_entity_loader' ) ) libxml_disable_entity_loader();
Expand Down

0 comments on commit 56e0369

Please sign in to comment.