Преглед на файлове

(refactoring) Generate database and "instance" UUIDs upon installation/upgrade.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4757 a333f486-631f-4898-b8df-5754b55c2be0
dflaven преди 8 години
родител
ревизия
d7a0fb642d
променени са 1 файла, в които са добавени 17 реда и са изтрити 0 реда
  1. 17 0
      setup/applicationinstaller.class.inc.php

+ 17 - 0
setup/applicationinstaller.class.inc.php

@@ -541,6 +541,15 @@ class ApplicationInstaller
 			
 			file_put_contents($sFileToPatch, $sContent);
 		}
+		
+		// Set an "Instance UUID" identifying this machine based on a file located in the data directory
+		$sInstanceUUIDFile = APPROOT.'data/instance.txt';
+		Setuputils::builddir(APPROOT.'data');
+		if (!file_exists($sInstanceUUIDFile))
+		{
+			$sIntanceUUID = utils::CreateUUID('filesystem');
+			file_put_contents($sInstanceUUIDFile, $sIntanceUUID);
+		}
 	}
 	
 	protected static function DoUpdateDBSchema($sMode, $aSelectedModules, $sModulesDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sTargetEnvironment  = '', $bOldAddon = false)
@@ -641,6 +650,14 @@ class ApplicationInstaller
 			throw new Exception("Failed to create/upgrade the database structure for environment '$sTargetEnvironment'");		
 		}
 		
+		// Set a DBProperty with a unique ID to identify this instance of iTop
+		$sUUID = DBProperty::GetProperty('database_uuid', '');
+		if ($sUUID === '')
+		{
+			$sUUID = utils::CreateUUID('database');
+			DBProperty::SetProperty('database_uuid', $sUUID, 'Installation/upgrade of '.ITOP_APPLICATION, 'Unique ID of this '.ITOP_APPLICATION.' Database');
+		}
+		
 		// priv_change now has an 'origin' field to distinguish between the various input sources
 		// Let's initialize the field with 'interactive' for all records were it's null
 		// Then check if some records should hold a different value, based on a pattern matching in the userinfo field