|
|
@@ -33,7 +33,7 @@ Lib::loadClass('SchemaVersionUpgrade');
|
|
|
class RefConfig {
|
|
|
|
|
|
// $REF_TABLE_VERSION = 5; // TODO: add unique key to (PRIMARY_KEY, REMOTE_PRIMARY_KEY)
|
|
|
- static $REF_TABLE_VERSION = 4;
|
|
|
+ static $REF_TABLE_VERSION = 5;
|
|
|
// $REF_TABLE_VERSION = 4; // added ref event log table - `CRM__#REF_LOG__*`
|
|
|
|
|
|
static function isActive($objectNamespace, $childTypeName) {
|
|
|
@@ -212,6 +212,7 @@ class RefConfig {
|
|
|
// 'VERSION' => self::$REF_TABLE_VERSION
|
|
|
]);
|
|
|
self::upgradeRefTableFrom1to2($refConfig);
|
|
|
+ self::upgradeRefTableFrom4to5($refConfig);
|
|
|
}
|
|
|
static function upgradeRefTableFrom1to2(Type_RefConfig $refConfig) { // TODO: rm ACL::upgradeRefConfigFrom1to2
|
|
|
if (1 == $refConfig->version) {
|
|
|
@@ -228,6 +229,21 @@ class RefConfig {
|
|
|
}
|
|
|
// TODO: return array_merge($refConfig, [ 'VERSION' => 2 ]);
|
|
|
}
|
|
|
+ static function upgradeRefTableFrom4to5(Type_RefConfig $refConfig) { // TODO: rm ACL::upgradeRefConfigFrom1to2
|
|
|
+ if ($refConfig->version < 5) {
|
|
|
+ if ('table' === $refConfig->source && 'NORMAL' == $refConfig->status) {
|
|
|
+ try {
|
|
|
+ DB::getPDO()->execSql(" ALTER TABLE `{$refConfig->tableName}` ADD `REF_PARAMS` varchar(1024) DEFAULT '' ");
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DBG::log($e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $affected = DB::getPDO()->update("CRM_REF_CONFIG", 'ID', $refConfig->id, [
|
|
|
+ 'VERSION' => 5
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ // TODO: return array_merge($refConfig, [ 'VERSION' => 2 ]);
|
|
|
+ }
|
|
|
|
|
|
static function installRefTable($objectNamespace, $childTypeName, Type_Field $newField, Type_RefConfig $refConfig = null) {
|
|
|
if (!$refConfig) $refConfig = self::fetch($objectNamespace, $childTypeName);
|
|
|
@@ -303,6 +319,7 @@ class RefConfig {
|
|
|
, backRef.A_STATUS as A_STATUS
|
|
|
, 0 as TRANSACTION_ID
|
|
|
, {$lastActionDateField} as A_LAST_ACTION_DATE
|
|
|
+ , backRef.REF_PARAMS as REF_PARAMS
|
|
|
from `{$backRefTable}` backRef
|
|
|
";
|
|
|
DBG::log($sql, 'sql', "generateRefSelectSqlByBackRef");
|
|
|
@@ -443,7 +460,8 @@ class RefConfig {
|
|
|
, 'WAITING' as A_STATUS
|
|
|
, 0 as TRANSACTION_ID
|
|
|
, {$lastActionDateField} as A_LAST_ACTION_DATE
|
|
|
- from `{$rootTableName}` root
|
|
|
+ , '' as REF_PARAMS
|
|
|
+ from `{$rootTableName}` root
|
|
|
join `{$childTableName}` child on(child.{$sqlChildFieldName} = root.{$appInfoChildFieldName})
|
|
|
where {$sqlWhereFromRestrictions}
|
|
|
";
|