Ver Fonte

upgrade db schema to version 8

Piotr Labudda há 8 anos atrás
pai
commit
b02f736b3e
1 ficheiros alterados com 33 adições e 6 exclusões
  1. 33 6
      SE/se-lib/SchemaVersionUpgrade.php

+ 33 - 6
SE/se-lib/SchemaVersionUpgrade.php

@@ -13,6 +13,9 @@
 // TODO: remove `CRM_INSTANCE_CONFIG`.`idInstanceBase`
 // TODO: DROP FUNCTION IF EXISTS `{$dbName}`.`isInstance_{$idInstance}` // for every instance
 
+// TODO: `CRM_REF_CONFIG` powinna zależeć od `CRM_#CACHE_ACL_OBJECT_FIELD`.isActive
+// TODO: `CRM_#CACHE_ACL_OBJECT_FIELD` add field label - read from xsd/p5:label: |> !empty -> p5:label |> empty -> cut from ":" for ref fields
+
 class SchemaVersionUpgrade {
 
 	static $REF_DB_SCHEMA_VERSION = 2;
@@ -59,11 +62,17 @@ class SchemaVersionUpgrade {
 			$_SESSION['_DB_SCHEMA_VERSION'] = 7;
 			self::_updateDBVersion(7);
 		}
-		// if ($_DB_SCHEMA_VERSION < 8) {
-		// 	self::_upgradeFrom7To8();
-		// 	$_DB_SCHEMA_VERSION = 8;
-		// 	$_SESSION['_DB_SCHEMA_VERSION'] = 8;
-		// 	self::_updateDBVersion(8);
+		if ($_DB_SCHEMA_VERSION < 8) {
+			self::_upgradeFrom7To8();
+			$_DB_SCHEMA_VERSION = 8;
+			$_SESSION['_DB_SCHEMA_VERSION'] = 8;
+			self::_updateDBVersion(8);
+		}
+		// if ($_DB_SCHEMA_VERSION < 9) {
+		// 	self::_upgradeFrom8To9();
+		// 	$_DB_SCHEMA_VERSION = 9;
+		// 	$_SESSION['_DB_SCHEMA_VERSION'] = 9;
+		// 	self::_updateDBVersion(9);
 		// }
 	}
 
@@ -360,7 +369,25 @@ class SchemaVersionUpgrade {
 		}
 	}
 
-	// static function _upgradeFrom7To8() {
+	static function _upgradeFrom7To8() {
+		try {
+			DB::getPDO()->execSql(" ALTER TABLE `CRM_#CACHE_ACL_OBJECT_FIELD` CHANGE `xsdRestrictions` `xsdRestrictions` text default null ");
+		} catch (Exception $e) {
+			DBG::log($e);
+		}
+		try {
+			DB::getPDO()->execSql(" ALTER TABLE `CRM_#CACHE_ACL_OBJECT_FIELD` CHANGE `appInfo` `appInfo` text default null ");
+		} catch (Exception $e) {
+			DBG::log($e);
+		}
+		try {
+			DB::getPDO()->execSql(" ALTER TABLE `CRM_#CACHE_ACL_OBJECT` ADD `appInfo` text default null ");
+		} catch (Exception $e) {
+			DBG::log($e);
+		}
+	}
+
+	// static function _upgradeFrom8To9() {
 	// }
 
 }