mirror of
https://github.com/Oreolek/kohana-migrations.git
synced 2024-06-28 20:55:08 +03:00
Moving logic for searching for available migrations into the model
Also added a method for getting the status of all locations, regaurdless of whether they're installed.
This commit is contained in:
parent
676f364ecd
commit
f4538e6713
|
@ -209,7 +209,7 @@ class Minion_Migration_Manager {
|
||||||
// Get array of installed migrations with the id as key
|
// Get array of installed migrations with the id as key
|
||||||
$installed = $this->_model->fetch_all('id');
|
$installed = $this->_model->fetch_all('id');
|
||||||
|
|
||||||
$available = $this->scan_for_migrations();
|
$available = $this->_model->available_migrations();
|
||||||
|
|
||||||
$all_migrations = array_keys($installed) + array_keys($available);
|
$all_migrations = array_keys($installed) + array_keys($available);
|
||||||
|
|
||||||
|
@ -242,25 +242,6 @@ class Minion_Migration_Manager {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Scans all migration directories for available migration files
|
|
||||||
*
|
|
||||||
* Returns an array of
|
|
||||||
*
|
|
||||||
* migration_id => array(
|
|
||||||
* 'file' => migration_file,
|
|
||||||
* 'location' => migration_location
|
|
||||||
* );
|
|
||||||
*
|
|
||||||
* @param return array
|
|
||||||
*/
|
|
||||||
public function scan_for_migrations()
|
|
||||||
{
|
|
||||||
$files = Kohana::list_files('migrations');
|
|
||||||
|
|
||||||
return Minion_Migration_Util::compile_migrations_from_files($files);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a database connection for running the migrations
|
* Gets a database connection for running the migrations
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,6 +28,42 @@ class Model_Minion_Migration extends Model
|
||||||
$this->_db = $db;
|
$this->_db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of migrations that are available in the filesystem
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function available_migrations()
|
||||||
|
{
|
||||||
|
$files = Kohana::list_files('migrations');
|
||||||
|
|
||||||
|
return Minion_Migration_Util::compile_migrations_from_files($files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the status of all locations, whether they're in the db or not.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_location_statuses()
|
||||||
|
{
|
||||||
|
// Start out using all the installed locations
|
||||||
|
$locations = $this->fetch_current_versions('location', 'id');
|
||||||
|
$available = $this->available_migrations();
|
||||||
|
|
||||||
|
foreach($available as $migration)
|
||||||
|
{
|
||||||
|
if(array_key_exists($migration['id'], $locations))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$locations[$migration['location']] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $locations;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or Set the table to use to store migrations
|
* Get or Set the table to use to store migrations
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue