Skip to content
Browse files

Adding isset() checks for CakeSchema::compare() when diff'ing db inde…

…xes.

Allows for slightly better interoperability between schemas generated with CakePHP 1.2 and with 1.3
  • Loading branch information...
1 parent 026eeb6 commit 730153b1516f368a73dcae8efcfa025b9187b062 @jperras jperras committed
Showing with 7 additions and 3 deletions.
  1. +7 −3 cake/libs/model/schema.php
View
10 cake/libs/model/schema.php
@@ -168,7 +168,7 @@ function load($options = array()) {
* Reads database and creates schema tables
*
* Options
- *
+ *
* - 'connection' - the db connection to use
* - 'name' - name of the schema
* - 'models' - a list of models to use, or false to ignore models
@@ -428,8 +428,12 @@ function compare($old, $new = null) {
if (isset($old[$table]['indexes']) && isset($new[$table]['indexes'])) {
$diff = $this->_compareIndexes($new[$table]['indexes'], $old[$table]['indexes']);
if ($diff) {
- $tables[$table]['drop']['indexes'] = $diff['drop'];
- $tables[$table]['add']['indexes'] = $diff['add'];
+ if (isset($tables[$table]['drop']['indexes']) && isset($diff['drop'])) {
+ $tables[$table]['drop']['indexes'] = $diff['drop'];
+ }
+ if (isset($tables[$table]['add']['indexes']) && isset($diff['add'])) {
+ $tables[$table]['add']['indexes'] = $diff['add'];
+ }
}
}
}

0 comments on commit 730153b

Please sign in to comment.
Something went wrong with that request. Please try again.