mirror of
https://github.com/Oreolek/kohana-migrations.git
synced 2024-06-26 03:40:54 +03:00
removing default path from configuration and adding support for --location
This commit is contained in:
parent
0eba2a0f02
commit
7b0fc8bdb6
|
@ -35,7 +35,8 @@ class Minion_Task_Db_Generate extends Minion_Task
|
||||||
*/
|
*/
|
||||||
protected $_config = array(
|
protected $_config = array(
|
||||||
'group',
|
'group',
|
||||||
'description'
|
'description',
|
||||||
|
'location'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,10 +55,16 @@ class Minion_Task_Db_Generate extends Minion_Task
|
||||||
$group = $config['group'].'/';
|
$group = $config['group'].'/';
|
||||||
$description = $config['description'];
|
$description = $config['description'];
|
||||||
|
|
||||||
|
if (empty($config['location']))
|
||||||
|
{
|
||||||
|
$config['location'] = APPPATH;
|
||||||
|
}
|
||||||
|
$location = rtrim(realpath($config['location']), '/').'/migrations/';
|
||||||
|
|
||||||
// {year}{month}{day}{hour}{minute}{second}
|
// {year}{month}{day}{hour}{minute}{second}
|
||||||
$time = date('YmdHis');
|
$time = date('YmdHis');
|
||||||
$class = $this->_generate_classname($group, $time);
|
$class = $this->_generate_classname($group, $time);
|
||||||
$file = $this->_generate_filename($group, $time, $description);
|
$file = $this->_generate_filename($location, $group, $time, $description);
|
||||||
|
|
||||||
|
|
||||||
$data = Kohana::FILE_SECURITY.View::factory('minion/task/db/generate/template')
|
$data = Kohana::FILE_SECURITY.View::factory('minion/task/db/generate/template')
|
||||||
|
@ -106,10 +113,10 @@ class Minion_Task_Db_Generate extends Minion_Task
|
||||||
* @param string Description
|
* @param string Description
|
||||||
* @return string Filename
|
* @return string Filename
|
||||||
*/
|
*/
|
||||||
public function _generate_filename($group, $time, $description)
|
public function _generate_filename($location, $group, $time, $description)
|
||||||
{
|
{
|
||||||
$description = substr(strtolower($description), 0, 100);
|
$description = substr(strtolower($description), 0, 100);
|
||||||
return DOCROOT.Kohana::config('minion/migration')->default_path.$group.$time.'_'.preg_replace('~[^a-z]+~', '-', $description).EXT;
|
return $location.$group.$time.'_'.preg_replace('~[^a-z]+~', '-', $description).EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue