Subversion Repositories oidplus

Rev

Rev 865 | Rev 1100 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. use ViaThinkSoft\OIDplus\OIDplusDatabaseConnection;
  21.  
  22. /**
  23.  * This function will be called by OIDplusDatabaseConnection.class.php at method afterConnect().
  24.  * @param OIDplusDatabaseConnection $db is the OIDplusDatabaseConnection class
  25.  * @return int new version set
  26.  * @throws \ViaThinkSoft\OIDplus\OIDplusException
  27.  */
  28. function oidplus_dbupdate_1001(OIDplusDatabaseConnection $db) {
  29.  
  30.         // Change collation so that objects like FourCC can be case-sensitive
  31.         if ($db->getSlang()->id() == 'mysql') {
  32.                 $db->query("ALTER TABLE ###asn1id     CHANGE `oid`    `oid`    varchar(255) NOT NULL     COLLATE utf8_bin;");
  33.                 $db->query("ALTER TABLE ###iri        CHANGE `oid`    `oid`    varchar(255) NOT NULL     COLLATE utf8_bin;");
  34.                 $db->query("ALTER TABLE ###objects    CHANGE `id`     `id`     varchar(255) NOT NULL     COLLATE utf8_bin;");
  35.                 $db->query("ALTER TABLE ###objects    CHANGE `parent` `parent` varchar(255) DEFAULT NULL COLLATE utf8_bin;");
  36.                 $db->query("ALTER TABLE ###log_object CHANGE `object` `object` varchar(255) NOT NULL     COLLATE utf8_bin;");
  37.         } else if ($db->getSlang()->id() == 'mssql') {
  38.                 $db->query("ALTER TABLE ###asn1id     ALTER COLUMN [oid]    varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
  39.                 $db->query("ALTER TABLE ###iri        ALTER COLUMN [oid]    varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
  40.                 $db->query("ALTER TABLE ###objects    ALTER COLUMN [id]     varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
  41.                 $db->query("ALTER TABLE ###objects    ALTER COLUMN [parent] varchar(255) COLLATE German_PhoneBook_CS_AS NULL    ;");
  42.                 $db->query("ALTER TABLE ###log_object ALTER COLUMN [object] varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
  43.         } else if ($db->getSlang()->id() == 'oracle') {
  44.                 // On the Oracle DeveloperDays 2019 VM, the default behavior is case-sensitive.
  45.                 // Let's hope that this is true for all OIDplus environments
  46.                 // DM 31.05.2022 : Reproduction on Ubuntu+PostgreSQL also successful. The default is case-sensitive, like we want.
  47.         } else if ($db->getSlang()->id() == 'pgsql') {
  48.                 // It looks like PgSQL is case-sensitive by default
  49.                 // see https://stackoverflow.com/questions/18807276/how-to-make-my-postgresql-database-use-a-case-insensitive-collation
  50.                 // DM 31.05.2022 : Reproduction on Ubuntu+PostgreSQL successful. The default is case-sensitive, like we want.
  51.         } else if ($db->getSlang()->id() == 'access') {
  52.                 // TODO: Implement
  53.                 // However, this is not important, because Access is not yet correctly implemented anyway
  54.         } else if ($db->getSlang()->id() == 'sqlite') {
  55.                 // It looks like SQLite is case-sensitive by default
  56.                 // https://stackoverflow.com/questions/973541/how-to-set-sqlite3-to-be-case-insensitive-when-string-comparing
  57.                 // DM 05.06.2022 : Reproduction on Ubuntu successful. The default is case-sensitive, like we want.
  58.         } else {
  59.                 // This should not happen
  60.         }
  61.  
  62.         $version = 1001;
  63.         $db->query("UPDATE ###config SET value = ? WHERE name = 'database_version'", array($version));
  64.  
  65.         return $version;
  66. }
  67.