aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/database.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-05-22 16:33:19 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-05-22 16:33:19 +0000
commit96031d570093d321dab15d5a7ceec899af0fa7e5 (patch)
tree30ae6fec480d47220d6647ab23ed07d48db01b0a /engine/lib/database.php
parent6615b6f4d827811046564cd004bd167b4c3c38bf (diff)
downloadelgg-96031d570093d321dab15d5a7ceec899af0fa7e5.tar.gz
elgg-96031d570093d321dab15d5a7ceec899af0fa7e5.tar.bz2
Refs #965: Allowing upgrades to be loaded from other locations.
git-svn-id: https://code.elgg.org/elgg/trunk@3301 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/database.php')
-rw-r--r--engine/lib/database.php27
1 files changed, 20 insertions, 7 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 9db5cf37c..4aa879920 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -515,23 +515,36 @@
}
}
-
- function db_upgrade($version) {
+
+ /**
+ * Upgrade the database schema in an ordered sequence.
+ *
+ * Makes use of schema upgrade files
+ *
+ * This is a about as core as it comes, so don't start running this from your plugins!
+ *
+ * @param int $version The version you are upgrading from (usually given in the Elgg version format of YYYYMMDDXX - see version.php for example)
+ * @param string $fromdir Optional directory to load upgrades from (default: engine/schema/upgrades/)
+ * @return bool
+ */
+ function db_upgrade($version, $fromdir = "") {
global $CONFIG;
// Elgg and its database must be installed to upgrade it!
- if (!is_db_installed() || !is_installed()) return false;
+ if (!is_db_installed() || !is_installed()) return false;
- $version = (int) $version;
+ $version = (int) $version;
+ if (!$fromdir)
+ $fromdir = $CONFIG->path . 'engine/schema/upgrades/';
- if ($handle = opendir($CONFIG->path . 'engine/schema/upgrades/')) {
+ if ($handle = opendir($fromdir)) {
$sqlupgrades = array();
while ($sqlfile = readdir($handle)) {
- if (!is_dir($CONFIG->path . 'engine/schema/upgrades/' . $sqlfile)) {
+ if (!is_dir($fromdir . $sqlfile)) {
if (preg_match('/([0-9]*)\.sql/',$sqlfile,$matches)) {
$sql_version = (int) $matches[1];
if ($sql_version > $version) {
@@ -546,7 +559,7 @@
if (sizeof($sqlupgrades) > 0) {
foreach($sqlupgrades as $sqlfile) {
try {
- run_sql_script($CONFIG->path . 'engine/schema/upgrades/' . $sqlfile);
+ run_sql_script($fromdir . $sqlfile);
} catch (DatabaseException $e) {
error_log($e->getmessage());
}