2014-10-09 140 views
0

我想用Cake模式更新mysql數據庫。在舊數據庫中,我有2個表格。而在我嘗試更新的新版本中,還有2個新表格。控制檯架構更新和新表

當我執行cake schema update,它拋出一個錯誤:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.new_table' doesn't exist

很明顯,因爲這些2個新表不存在,所以CakeConsole應該先創建。

我使用的是2.3版本。有沒有任何選項來糾正這個錯誤?或者它在更高版本中解決?

回答

0

最後我升級到最新版本(2.5.5)。而現在,模式更新完美地工作。因爲在SchemaShell.php的第379-393行有一些變化,這些變化檢查表是否存在。

if (empty($table)) { 
    foreach ($compare as $table => $changes) { 
     if (isset($compare[$table]['create'])) { 
      $contents[$table] = $db->createSchema($Schema, $table); 
     } else { 
      $contents[$table] = $db->alterSchema(array($table => $compare[$table]), $table); 
     } 
    } 
} elseif (isset($compare[$table])) { 
    if (isset($compare[$table]['create'])) { 
     $contents[$table] = $db->createSchema($Schema, $table); 
    } else { 
     $contents[$table] = $db->alterSchema(array($table => $compare[$table]), $table); 
    } 
}