Explorar o código

Renamed priv_Userinternal into priv_userinternal, and added a check for table names (lowercase is the rule!)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2435 a333f486-631f-4898-b8df-5754b55c2be0
romainq %!s(int64=12) %!d(string=hai) anos
pai
achega
8eeea2f197

+ 8 - 0
core/metamodel.class.php

@@ -3175,6 +3175,14 @@ abstract class MetaModel
 		$aSugFix = array();
 		foreach (self::GetClasses() as $sClass)
 		{
+			$sTable = self::DBGetTable($sClass);
+			$sTableLowercase = strtolower($sTable);
+			if ($sTableLowercase != $sTable)
+			{
+				$aErrors[$sClass][] = "Table name '".$sTable."' has upper case characters. You might encounter issues when moving your installation between Linux and Windows.";
+				$aSugFix[$sClass][] = "Use '$sTableLowercase' instead. Step 1: If already installed, then rename manually in the DB: RENAME TABLE `$sTable` TO `{$sTableLowercase}_tempname`, `{$sTableLowercase}_tempname` TO `$sTableLowercase`; Step 2: Rename the table in the datamodel and compile the application. Note: the MySQL statement provided in step 1 has been designed to be compatible with Windows or Linux.";
+			}
+
 			$aNameSpec = self::GetNameSpec($sClass);
 			foreach($aNameSpec[1] as $i => $sAttCode)
 			{

+ 1 - 1
core/userrights.class.inc.php

@@ -282,7 +282,7 @@ abstract class UserInternal extends User
 			"name_attcode" => "login",
 			"state_attcode" => "",
 			"reconc_keys" => array('login'),
-			"db_table" => "priv_internalUser",
+			"db_table" => "priv_internaluser",
 			"db_key_field" => "id",
 			"db_finalclass_field" => "",
 		);

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

@@ -532,6 +532,21 @@ class ApplicationInstaller
 		$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
 		$oProductionEnv->InitDataModel($oConfig, true);  // load data model only
 
+		// Migrate application data format
+		//
+		// priv_internalUser caused troubles because MySQL transforms table names to lower case under Windows
+		// This becomes an issue when moving your installation data to/from Windows
+		// Starting 2.0, all table names must be lowercase
+		if ($sMode != 'install')
+		{
+			SetupPage::log_info("Renaming 'priv_internalUser' into 'priv_internaluser' (lowercase)"); 
+			// This command will have no effect under Windows...
+			// and it has been written in two steps so as to make it work under windows!
+			$sRepair = "RENAME TABLE `priv_internalUser` TO `priv_internaluser_other`, `priv_internaluser_other` TO `priv_internaluser`";
+			CMDBSource::SelectDB($sDBName);
+			CMDBSource::Query($sRepair);
+		}
+
 		// Module specific actions (migrate the data)
 		//
 		$aAvailableModules = $oProductionEnv->AnalyzeInstallation(MetaModel::GetConfig(), APPROOT.$sModulesDir);