diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index 940b4a1f3dc..2944e6afff0 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -491,7 +491,7 @@ function compare($old, $new = null) { } } - if (isset($add[$table][$field])) { + if (isset($tables[$table]['add'][$field]) && $field !== 'indexes' && $field !== 'tableParameters') { $wrapper = array_keys($fields); if ($column = array_search($field, $wrapper)) { if (isset($wrapper[$column - 1])) { diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php index 65ca3ce5952..3e646145d3f 100644 --- a/cake/tests/cases/libs/model/cake_schema.test.php +++ b/cake/tests/cases/libs/model/cake_schema.test.php @@ -741,8 +741,8 @@ function testSchemaComparison() { $expected = array( 'comments' => array( 'add' => array( - 'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'title' => array('type' => 'string', 'null' => false, 'length' => 100), + 'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'after' => 'id'), + 'title' => array('type' => 'string', 'null' => false, 'length' => 100, 'after' => 'user_id'), ), 'drop' => array( 'article_id' => array('type' => 'integer', 'null' => false), @@ -754,7 +754,7 @@ function testSchemaComparison() { ), 'posts' => array( 'add' => array( - 'summary' => array('type' => 'text', 'null' => 1), + 'summary' => array('type' => 'text', 'null' => 1, 'after' => 'body'), ), 'drop' => array( 'tableParameters' => array(), @@ -795,11 +795,11 @@ function testSchemaComparison() { 'ratings' => array( 'add' => array( 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'), - 'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => NULL), - 'model' => array('type' => 'varchar', 'null' => false, 'default' => NULL), - 'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => NULL), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL), - 'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL), + 'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'after' => 'id'), + 'model' => array('type' => 'varchar', 'null' => false, 'default' => NULL, 'after' => 'foreign_key'), + 'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => NULL, 'after' => 'model'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL, 'after' => 'value'), + 'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL, 'after' => 'created'), 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)), 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM') )