Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Add a simple ajxp_version table in DB to keep DB build number
Browse files Browse the repository at this point in the history
Optionaly set the version info inside a PHP file instead of text file to optimize loading (can be opcached, not the text version)
  • Loading branch information
cdujeu committed Nov 29, 2014
1 parent e6e713b commit 4aca084
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/conf/VERSION
@@ -1 +1 @@
##VERSION_NUMBER##__##VERSION_DATE##__##REVISION##
##VERSION_NUMBER##__##VERSION_DATE##__##REVISION##__##DB_VERSION##
5 changes: 5 additions & 0 deletions core/src/conf/VERSION.php
@@ -0,0 +1,5 @@
<?php
define("AJXP_VERSION", "##VERSION_NUMBER##");
define("AJXP_VERSION_DATE", "##VERSION_DATE##");
define("AJXP_VERSION_REV", "##REVISION##");
define("AJXP_VERSION_DB", "##DB_VERSION##");
11 changes: 8 additions & 3 deletions core/src/conf/bootstrap_context.php
Expand Up @@ -30,9 +30,14 @@
//setlocale(LC_ALL, '');
@libxml_disable_entity_loader(false);

list($vNmber,$vDate) = explode("__",file_get_contents(AJXP_CONF_PATH."/VERSION"));
define("AJXP_VERSION", $vNmber);
define("AJXP_VERSION_DATE", $vDate);
@include_once("VERSION.php");
if(!defined("AJXP_VERSION")){
list($vNmber,$vDate,$vRevision,$vDbVersion) = explode("__",file_get_contents(AJXP_CONF_PATH."/VERSION"));
define("AJXP_VERSION", $vNmber);
define("AJXP_VERSION_DATE", $vDate);
if(!empty($vRevision)) define("AJXP_VERSION_REV", $vRevision);
if(!empty($vDbVersion)) define("AJXP_VERSION_DB", intval($vDbVersion));
}

define("AJXP_EXEC", true);

Expand Down
10 changes: 9 additions & 1 deletion core/src/plugins/conf.sql/class.sqlConfDriver.php
Expand Up @@ -1043,7 +1043,15 @@ public function pruneTemporaryKeys($keyType, $expiration)
public function installSQLTables($param)
{
$p = AJXP_Utils::cleanDibiDriverParameters($param["SQL_DRIVER"]);
return AJXP_Utils::runCreateTablesQuery($p, $this->getBaseDir()."/create.sql");
$res = AJXP_Utils::runCreateTablesQuery($p, $this->getBaseDir()."/create.sql");
// SET DB VERSION
if(defined('AJXP_VERSION_DB') && AJXP_VERSION_DB != "##DB_VERSION##"){
require_once(AJXP_BIN_FOLDER."/dibi.compact.php");
dibi::connect($p);
dibi::query("UPDATE [ajxp_version] SET [db_build]=%i", intval(AJXP_VERSION_DB));
dibi::disconnect();
}
return $res;
}

public function supportsUserTeams()
Expand Down
7 changes: 6 additions & 1 deletion core/src/plugins/conf.sql/create.mysql
Expand Up @@ -87,4 +87,9 @@ CREATE TABLE IF NOT EXISTS ajxp_user_teams (
team_label VARCHAR(255) NOT NULL,
owner_id varchar(255) NOT NULL,
PRIMARY KEY(team_id, user_id)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS ajxp_version (
db_build INT NOT NULL
);
INSERT INTO ajxp_version SET db_build=0;
6 changes: 6 additions & 0 deletions core/src/plugins/conf.sql/create.pgsql
Expand Up @@ -89,3 +89,9 @@ CREATE TABLE ajxp_user_teams (
owner_id varchar(255) NOT NULL,
PRIMARY KEY(team_id, user_id)
);

CREATE TABLE ajxp_version (
db_build INT NOT NULL
);

INSERT INTO ajxp_version VALUES (0);
8 changes: 7 additions & 1 deletion core/src/plugins/conf.sql/create.sqlite
Expand Up @@ -81,4 +81,10 @@ CREATE TABLE IF NOT EXISTS ajxp_user_teams (
user_id text NOT NULL,
team_label text NOT NULL,
owner_id text NOT NULL
);
);

CREATE TABLE IF NOT EXISTS ajxp_version (
db_build INT NOT NULL
);

INSERT INTO ajxp_version VALUES (0);

0 comments on commit 4aca084

Please sign in to comment.