Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 854 → Rev 855

/trunk/includes/db_updates/run.inc.php
68,7 → 68,9
$version = oidplus_dbupdate_205($db);
}
if ($version == 1000) {
// ... in the future, add updates here! ...
// Update 1000 => 1001
require_once __DIR__.'/update1001.inc.php';
$version = oidplus_dbupdate_1001($db);
}
} catch (Exception $e) {
throw new OIDplusException(_L('Database update from version %1 failed: %2',$version,$e->getMessage()));
75,8 → 77,7
}
 
// Don't allow if the database version if newer than we expect
if ($version != 1000) {
require_once __DIR__.'/update205.inc.php';
$version = oidplus_dbupdate_205($db);
if ($version > 1001) {
throw new OIDplusException(_L('The version of the database is newer than the program version. Please upgrade your program version.'));
}
}
/trunk/includes/db_updates/update1001.inc.php
0,0 → 1,63
<?php
 
/*
* OIDplus 2.0
* Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
 
/**
* This function will be called by OIDplusDatabaseConnection.class.php at method afterConnect().
* @param OIDplusDatabaseConnection $db is the OIDplusDatabaseConnection class
* @return int new version set
* @throws OIDplusException
*/
function oidplus_dbupdate_1001(OIDplusDatabaseConnection $db) {
 
// Change collation so that objects like FourCC can be case-sensitive
if ($db->getSlang()->id() == 'mysql') {
$db->query("ALTER TABLE ###asn1id CHANGE `oid` `oid` varchar(255) NOT NULL COLLATE utf8_bin;");
$db->query("ALTER TABLE ###iri CHANGE `oid` `oid` varchar(255) NOT NULL COLLATE utf8_bin;");
$db->query("ALTER TABLE ###objects CHANGE `id` `id` varchar(255) NOT NULL COLLATE utf8_bin;");
$db->query("ALTER TABLE ###objects CHANGE `parent` `parent` varchar(255) DEFAULT NULL COLLATE utf8_bin;");
$db->query("ALTER TABLE ###log_object CHANGE `object` `object` varchar(255) NOT NULL COLLATE utf8_bin;");
} else if ($db->getSlang()->id() == 'mssql') {
$db->query("ALTER TABLE ###asn1id ALTER COLUMN [oid] varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
$db->query("ALTER TABLE ###iri ALTER COLUMN [oid] varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
$db->query("ALTER TABLE ###objects ALTER COLUMN [id] varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
$db->query("ALTER TABLE ###objects ALTER COLUMN [parent] varchar(255) COLLATE German_PhoneBook_CS_AS NULL ;");
$db->query("ALTER TABLE ###log_object ALTER COLUMN [object] varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
} else if ($db->getSlang()->id() == 'oracle') {
// On the Oracle Developer VM, the default behavior is case-sensitive.
// Let's hope that this is true for all OIDplus environments
} else if ($db->getSlang()->id() == 'pgsql') {
// It looks like PgSQL is case-sensitive by default
// see https://stackoverflow.com/questions/18807276/how-to-make-my-postgresql-database-use-a-case-insensitive-collation
// TODO: Reproduce that this is true
} else if ($db->getSlang()->id() == 'access') {
// TODO: Implement
// However, this is not important, because Access is not yet correctly implemented anyway
} else if ($db->getSlang()->id() == 'sqlite') {
// It looks like SQLite is case-sensitive by default
// https://stackoverflow.com/questions/973541/how-to-set-sqlite3-to-be-case-insensitive-when-string-comparing
// TODO: Reproduce that this is true
} else {
// This should not happen
}
 
$version = 1001;
$db->query("UPDATE ###config SET value = ? WHERE name = 'database_version'", array($version));
 
return $version;
}