1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-05-24 11:58:11 +03:00

Improving the output of db:migrate to show number of migrations run & also status of locations

This commit is contained in:
Matt Button 2010-12-31 00:51:07 +00:00
parent 7ff67837b6
commit d463d9f873
3 changed files with 25 additions and 7 deletions

View file

@ -106,6 +106,15 @@ class Minion_Migration_Manager {
return $this->_dry_run_sql;
}
/**
* Returns a set of executed migrations
* @return array
*/
public function get_executed_migrations()
{
return $this->_executed_migrations;
}
/**
* Run migrations in the specified locations so as to reach specified targets
*
@ -194,6 +203,8 @@ class Minion_Migration_Manager {
{
$this->_model->mark_migration($migration, $location['direction']);
}
$this->_executed_migrations[] = $migration;
}
}
}

View file

@ -105,7 +105,9 @@ class Minion_Task_Db_Migrate extends Minion_Task
$view = View::factory('minion/task/db/migrate')
->set('dry_run', $dry_run)
->set('quiet', $quiet)
->set('dry_run_sql', $manager->get_dry_run_sql());
->set('dry_run_sql', $manager->get_dry_run_sql())
->set('executed_migrations', $manager->get_executed_migrations())
->set('location_versions', $model->fetch_current_versions());
return $view;
}

View file

@ -1,10 +1,17 @@
<? if( ! $quiet): ?>
Executed <?php echo count($executed_migrations); ?> migrations
Current versions of locations:
<?php foreach($location_versions as $location): ?>
* <?php echo $location['location'] ?> : <?php echo $location['timestamp'] ?> (<?php echo $location['description']; ?>)
<?php endforeach; ?>
<?php if($dry_run): ?>
<?php if( ! $quiet): ?>
This was a dry run, SQL is as follows:
This was a dry run, if it was a real run the following SQL would've been executed:
<?php endif; ?>
<?php endif; ?>
<?php foreach($dry_run_sql as $location => $migrations): ?>
<?php $location_padding = str_repeat('#', strlen($location)); ?>
##################<?php echo $location_padding ?>##
# Begin Location: <?php echo $location; ?> #
@ -27,5 +34,3 @@ This was a dry run, SQL is as follows:
################<?php echo $location_padding ?>##
<?php endforeach; ?>
<?php endif; ?>