mirror of
https://github.com/Oreolek/kohana-migrations.git
synced 2024-06-26 03:40:54 +03:00
moved generating of migration to public method so it can be used for other tasks
This commit is contained in:
parent
3c8d16ce55
commit
f30cca150b
|
@ -45,6 +45,20 @@ class Minion_Task_Db_Generate extends Minion_Task
|
||||||
* @param array Configuration
|
* @param array Configuration
|
||||||
*/
|
*/
|
||||||
public function execute(array $config)
|
public function execute(array $config)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$file = $this->generate($config);
|
||||||
|
Minion_CLI::write('Migration generated: '.$file);
|
||||||
|
}
|
||||||
|
catch(ErrorException $e)
|
||||||
|
{
|
||||||
|
Minion_CLI::write($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generate($config)
|
||||||
{
|
{
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'location' => APPPATH,
|
'location' => APPPATH,
|
||||||
|
@ -59,9 +73,7 @@ class Minion_Task_Db_Generate extends Minion_Task
|
||||||
|
|
||||||
if ( ! $this->_valid_group($config['group']))
|
if ( ! $this->_valid_group($config['group']))
|
||||||
{
|
{
|
||||||
Minion_CLI::write('Please provide a valid --group');
|
throw new ErrorException("Please provide a valid --group\nSee help for more info");
|
||||||
Minion_CLI::write('See help for more info');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = $config['group'].'/';
|
$group = $config['group'].'/';
|
||||||
|
@ -86,8 +98,7 @@ class Minion_Task_Db_Generate extends Minion_Task
|
||||||
|
|
||||||
file_put_contents($file, $data);
|
file_put_contents($file, $data);
|
||||||
|
|
||||||
Minion_CLI::write('Migration generated: '.$file);
|
return $file;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue