mirror of
https://github.com/Oreolek/kohana-migrations.git
synced 2024-06-28 20:55:08 +03:00
created possibility of writing generated code directly into migration
This commit is contained in:
parent
f30cca150b
commit
fca8ccdf77
|
@ -58,7 +58,7 @@ class Minion_Task_Db_Generate extends Minion_Task
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generate($config)
|
public function generate($config, $up = null, $down = null)
|
||||||
{
|
{
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'location' => APPPATH,
|
'location' => APPPATH,
|
||||||
|
@ -89,6 +89,8 @@ class Minion_Task_Db_Generate extends Minion_Task
|
||||||
$data = Kohana::FILE_SECURITY.View::factory('minion/task/db/generate/template')
|
$data = Kohana::FILE_SECURITY.View::factory('minion/task/db/generate/template')
|
||||||
->set('class', $class)
|
->set('class', $class)
|
||||||
->set('description', $description)
|
->set('description', $description)
|
||||||
|
->set('up', $up)
|
||||||
|
->set('down', $down)
|
||||||
->render();
|
->render();
|
||||||
|
|
||||||
if ( ! is_dir(dirname($file)))
|
if ( ! is_dir(dirname($file)))
|
||||||
|
|
|
@ -12,7 +12,12 @@ class <?php echo $class; ?> extends Minion_Migration_Base {
|
||||||
*/
|
*/
|
||||||
public function up(Kohana_Database $db)
|
public function up(Kohana_Database $db)
|
||||||
{
|
{
|
||||||
|
<?php if(!empty($up)): ?>
|
||||||
|
<?php echo $up; ?>
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
// $db->query(NULL, 'CREATE TABLE ... ');
|
// $db->query(NULL, 'CREATE TABLE ... ');
|
||||||
|
<?php endif; ?>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +27,11 @@ class <?php echo $class; ?> extends Minion_Migration_Base {
|
||||||
*/
|
*/
|
||||||
public function down(Kohana_Database $db)
|
public function down(Kohana_Database $db)
|
||||||
{
|
{
|
||||||
|
<?php if(!empty($down)): ?>
|
||||||
|
<?php echo $down; ?>
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
// $db->query(NULL, 'DROP TABLE ... ');
|
// $db->query(NULL, 'DROP TABLE ... ');
|
||||||
|
<?php endif; ?>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue