Skip to content

Commit

Permalink
fixed bug with empty column defs
Browse files Browse the repository at this point in the history
  • Loading branch information
dracony committed Jun 4, 2013
1 parent 0e2470e commit 7e49474
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions classes/PHPixie/Migrate/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected function apply($version_key, $direction) {
unset($columns['_data']);
}

if ($data_updates && $direction=='down')
if (!empty($data_updates) && $direction=='down')
$this->update_table_data($table, $data_updates);

if ($columns=='drop'&&$direction=='up') {
Expand Down Expand Up @@ -183,9 +183,7 @@ protected function apply($version_key, $direction) {
unset($columns['rename']);
}

if (empty($columns))
continue;


if (!$renamed&&!isset($current_schema[$table])){
$this->create_table($table, $target_schema[$target_table]);
continue;
Expand Down Expand Up @@ -231,8 +229,10 @@ protected function apply($version_key, $direction) {
}

$this->pixie-> debug->log(array($target_table, $columns));
$this->alter_columns($target_table, $columns);
if ($data_updates && $direction=='up')
if(!empty($columns))
$this->alter_columns($target_table, $columns);

if (!empty($data_updates) && $direction=='up')
$this->update_table_data($table, $data_updates);


Expand Down Expand Up @@ -304,7 +304,8 @@ public function get_version_schema($target) {
* @return void
*/
protected function update_table_data($table, $data) {
foreach ($this->pixie->arr($data, 'insert', array()) as $insert)

foreach ($this->pixie-> arr($data, 'insert', array()) as $insert)
$this->_db->query('insert')
->table($table)
->data($insert)
Expand Down

0 comments on commit 7e49474

Please sign in to comment.