UpdateDatabase/MysqlEngineCharset.php
[Pman.Core] / UpdateDatabase / MysqlEngineCharset.php
index 9a24456..82630ec 100644 (file)
@@ -13,10 +13,18 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
     
     function __construct()
     {
-          
+        // this might get run before we have imported the database
+        // and hence not have any db.
         $this->loadIniFiles(); //?? shared???
         
-        $dbo = DB_DataObject::factory('core_enum');
+        try {
+            $dbo = DB_DataObject::factory('core_enum');
+        } catch(PDO_DataObject_Exception_InvalidConfig $e) {
+            echo "SKipping MysqlEngineCharse - no database yet\n";
+            return;
+        }
+        
+        die("HERE");
         if (is_a($dbo, 'PDO_DataObject')) {
             
             $this->views = $dbo->generator()->introspection()->getListOf('views');
@@ -85,7 +93,7 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
                 WHERE
                         CCSA.collation_name = T.table_collation
                     AND
-                        T.table_schema = '{$ce->database()}' -- COLLATE utf8_general_ci
+                        T.table_schema = DATABASE() -- COLLATE utf8_general_ci
                     AND
                         T.table_name = '{$tbl}' -- COLLATE utf8_general_ci
             ");
@@ -114,17 +122,24 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
         $db = DB_DataObject::factory('core_enum');
         $db->query("show variables like 'innodb_file_per_table'");
         $db->fetch();
-        if ($db->Value == 'OFF') {
-            die("Error: set innodb_file_per_table = 1 in my.cnf\n\n");
+        
+        $pg = HTML_FlexyFramework::get()->page;
+        
+        if (empty($pg->opts['skip-mysql-checks'])) {
+            if ($db->Value == 'OFF') {
+                die("Error: set innodb_file_per_table = 1 in my.cnf\n\n");
+            }
+            
         }
         
+        
         // get a list of table views...
         // innodb in single files is far more efficient that MYD or one big innodb file.
         // first check if database is using this format.
         
         
         
-        
+        $views = $this->views;
         
         
         foreach (array_keys($this->schema) as $tbl){
@@ -132,6 +147,7 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
             if(strpos($tbl, '__keys') !== false ){
                 continue;
             }
+            
             if(in_array($tbl , $views)) {
                 continue;
             }
@@ -152,11 +168,20 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
             if (!$ce->fetch()) {
                 continue;
             }
+            //AWS is returning captials?
+            $engine = isset($ce->engine) ? $ce->engine : $ce->ENGINE;
             
-            if($ce->engine == 'InnoDB' ){
+            if($engine == 'InnoDB' ){
                 echo "InnoDB: SKIP $tbl\n";
                 continue;
             }
+            if($engine == 'ndbcluster' ){
+                echo "ndbcluster: SKIP $tbl\n";
+                continue;
+            }
+            
+            // should really determine if we are running in cluster ready ...
+            
             // this used to be utf8_unicode_ci
             //as the default collation for stored procedure parameters is utf8_general_ci and you can't mix collations.