Subversion Repositories oidplus

Rev

Rev 863 | Rev 1050 | 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. /**
  21.  * This function will be called by OIDplusDatabaseConnection.class.php at method afterConnect().
  22.  * @param OIDplusDatabaseConnection $db is the OIDplusDatabaseConnection class
  23.  * @return int new version set
  24.  * @throws OIDplusException
  25.  */
  26. function oidplus_dbupdate_1001(OIDplusDatabaseConnection $db) {
  27.  
  28.         // Change collation so that objects like FourCC can be case-sensitive
  29.         if ($db->getSlang()->id() == 'mysql') {
  30.                 $db->query("ALTER TABLE ###asn1id     CHANGE `oid`    `oid`    varchar(255) NOT NULL     COLLATE utf8_bin;");
  31.                 $db->query("ALTER TABLE ###iri        CHANGE `oid`    `oid`    varchar(255) NOT NULL     COLLATE utf8_bin;");
  32.                 $db->query("ALTER TABLE ###objects    CHANGE `id`     `id`     varchar(255) NOT NULL     COLLATE utf8_bin;");
  33.                 $db->query("ALTER TABLE ###objects    CHANGE `parent` `parent` varchar(255) DEFAULT NULL COLLATE utf8_bin;");
  34.                 $db->query("ALTER TABLE ###log_object CHANGE `object` `object` varchar(255) NOT NULL     COLLATE utf8_bin;");
  35.         } else if ($db->getSlang()->id() == 'mssql') {
  36.                 $db->query("ALTER TABLE ###asn1id     ALTER COLUMN [oid]    varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
  37.                 $db->query("ALTER TABLE ###iri        ALTER COLUMN [oid]    varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
  38.                 $db->query("ALTER TABLE ###objects    ALTER COLUMN [id]     varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
  39.                 $db->query("ALTER TABLE ###objects    ALTER COLUMN [parent] varchar(255) COLLATE German_PhoneBook_CS_AS NULL    ;");
  40.                 $db->query("ALTER TABLE ###log_object ALTER COLUMN [object] varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
  41.         } else if ($db->getSlang()->id() == 'oracle') {
  42.                 // On the Oracle DeveloperDays 2019 VM, the default behavior is case-sensitive.
  43.                 // Let's hope that this is true for all OIDplus environments
  44.                 // DM 31.05.2022 : Reproduction on Ubuntu+PostgreSQL also successful. The default is case-sensitive, like we want.
  45.         } else if ($db->getSlang()->id() == 'pgsql') {
  46.                 // It looks like PgSQL is case-sensitive by default
  47.                 // see https://stackoverflow.com/questions/18807276/how-to-make-my-postgresql-database-use-a-case-insensitive-collation
  48.                 // DM 31.05.2022 : Reproduction on Ubuntu+PostgreSQL successful. The default is case-sensitive, like we want.
  49.         } else if ($db->getSlang()->id() == 'access') {
  50.                 // TODO: Implement
  51.                 // However, this is not important, because Access is not yet correctly implemented anyway
  52.         } else if ($db->getSlang()->id() == 'sqlite') {
  53.                 // It looks like SQLite is case-sensitive by default
  54.                 // https://stackoverflow.com/questions/973541/how-to-set-sqlite3-to-be-case-insensitive-when-string-comparing
  55.                 // DM 05.06.2022 : Reproduction on Ubuntu successful. The default is case-sensitive, like we want.
  56.         } else {
  57.                 // This should not happen
  58.         }
  59.  
  60.         $version = 1001;
  61.         $db->query("UPDATE ###config SET value = ? WHERE name = 'database_version'", array($version));
  62.  
  63.         return $version;
  64. }
  65.