1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-06-16 23:11:06 +03:00

Refactored the migration model slightly, reduces the complexity and removes stupid code that shouldn't have been there in the first place

This commit is contained in:
Matt Button 2010-12-31 00:49:09 +00:00
parent e4d8c740b5
commit 7ff67837b6

View file

@ -190,6 +190,20 @@ class Model_Minion_Migration extends Model
->as_array($key, $value);
}
/**
* Fetches a list of locations
*
* @return array
*/
public function fetch_locations($location_as_key = FALSE)
{
return DB::select()
->from($this->_table)
->group_by('location')
->execute($this->_db)
->as_array($location_as_key ? 'location' : NULL, 'location');
}
/**
* Fetch a list of migrations that need to be applied in order to reach the
* required version
@ -216,16 +230,8 @@ class Model_Minion_Migration extends Model
// The user wants to run all available migrations
if(empty($locations))
{
if(count($migrations))
{
$keys = array_keys($migrations);
$locations = array_combine($keys, $keys);
}
else
{
$locations = $this->fetch_all('location', 'location');
}
// Fetch a mirrored array of locations => locations
$locations = $this->fetch_locations(TRUE);
}
// If the calling script has been lazy and given us a numerically
// indexed array of locations then we need to convert it to a mirrored