Setup adjust

This commit is contained in:
kaetemi 2014-09-08 00:06:13 +02:00
parent 6a3d59f6f5
commit d7c1249b6b
4 changed files with 47 additions and 30 deletions

View file

@ -137,7 +137,7 @@ $NEL_SETUP_PASSWORD = '%nelSetupPassword%';
$NEL_DOMAIN_NAME = '%nelDomainName%';
// Currently configured setup version
$NEL_SETUP_VERSION_CONFIGURED = '%nelSetupVersion%';
$NEL_SETUP_VERSION_CONFIGURED = (int)'%nelSetupVersion%';
// Get installed version
require_once('setup/version.php');

View file

@ -20,11 +20,18 @@ try {
if (!file_exists('../role_support')) {
header("Cache-Control: max-age=1");
header('Location: ../setup', true, 303);
header('Location: ../setup?reason=no_role_support&from=ams', true, 303);
throw new SystemExit();
}
require( '../config.php' );
if ($NEL_SETUP_VERSION_CONFIGURED < $NEL_SETUP_VERSION) {
header("Cache-Control: max-age=1");
header('Location: ../setup?reason=upgrade&from=ams', true, 303);
throw new SystemExit();
}
require_once( $AMS_LIB . '/libinclude.php' );
session_start();

View file

@ -1,5 +1,17 @@
<?php
// Service
$db_nel = 3;
$db_nel_tool = 1;
// Support
$db_nel_ams = 1
$db_nel_ams_lib = 3;
// Domain
$db_ring_domain = 1;
function set_db_version($continue_r, $name, $version) {
$continue = $continue_r;
@ -53,26 +65,22 @@ function upgrade_service_databases($continue_r) {
$con = null;
$con = connect_database($continue, "shard");
$continue = ($con != null);
if ($continue && get_db_version("shard") < 1) {
$continue = update_database_structure($continue, $con, "nel_00001.sql");
$continue = set_db_version($continue, "shard", 1);
}
if ($continue && get_db_version("shard") < 2) {
$continue = update_database_structure($continue, $con, "nel_00002.sql");
$continue = set_db_version($continue, "shard", 2);
}
if ($continue && get_db_version("shard") < 3) {
$continue = update_database_structure($continue, $con, "nel_00003.sql");
$continue = set_db_version($continue, "shard", 3);
for ($i = 1; $i <= $db_nel; $i++) {
if ($continue && get_db_version("shard") < $i) {
$continue = update_database_structure($continue, $con, "nel_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "shard", $i);
}
}
disconnect_database($con, "shard");
$con = null;
$con = connect_database($continue, "tool");
$continue = ($con != null);
if ($continue && get_db_version("tool") < 1) {
$continue = update_database_structure($continue, $con, "nel_tool_00001.sql");
$continue = set_db_version($continue, "tool", 1);
for ($i = 1; $i <= $db_nel_tool; $i++) {
if ($continue && get_db_version("tool") < $i) {
$continue = update_database_structure($continue, $con, "nel_tool_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "tool", $i);
}
}
disconnect_database($con, "tool");
@ -85,22 +93,22 @@ function upgrade_support_databases($continue_r) {
$con = null;
$con = connect_database($continue, "web");
$continue = ($con != null);
if ($continue && get_db_version("web") < 1) {
$continue = update_database_structure($continue, $con, "nel_ams_00001.sql");
$continue = set_db_version($continue, "web", 1);
for ($i = 1; $i <= $db_nel_ams; $i++) {
if ($continue && get_db_version("web") < $i) {
$continue = update_database_structure($continue, $con, "nel_ams_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "web", $i);
}
}
disconnect_database($con, "web");
$con = null;
$con = connect_database($continue, "lib");
$continue = ($con != null);
if ($continue && get_db_version("lib") < 1) {
$continue = update_database_structure($continue, $con, "nel_ams_lib_00001.sql");
$continue = set_db_version($continue, "lib", 1);
}
if ($continue && get_db_version("lib") < 2) {
$continue = update_database_structure($continue, $con, "nel_ams_lib_00002.sql");
$continue = set_db_version($continue, "lib", 2);
for ($i = 1; $i <= $db_nel_ams_lib; $i++) {
if ($continue && get_db_version("lib") < $i) {
$continue = update_database_structure($continue, $con, "nel_ams_lib_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "lib", $i);
}
}
disconnect_database($con, "lib");
@ -113,9 +121,11 @@ function upgrade_domain_databases($continue_r) {
$con = null;
$con = connect_database($continue, "ring");
$continue = ($con != null);
if ($continue && get_db_version("ring") < 1) {
$continue = update_database_structure($continue, $con, "ring_domain_00001.sql");
$continue = set_db_version($continue, "ring", 1);
for ($i = 1; $i <= $db_ring_domain; $i++) {
if ($continue && get_db_version("ring") < $i) {
$continue = update_database_structure($continue, $con, "ring_domain_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql");
$continue = set_db_version($continue, "ring", $i);
}
}
disconnect_database($con, "ring");

View file

@ -1,6 +1,6 @@
<?php
// Increment whenever a web upgrade is required.
$NEL_SETUP_VERSION = 3;
$NEL_SETUP_VERSION = 4;
/* end of file */