1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-06-26 03:40:54 +03:00

Merge branch '3.1/develop' into 3.2/develop

This commit is contained in:
Lorenzo Pisani 2011-07-01 20:57:27 -07:00
commit 745c40dfc9
7 changed files with 35 additions and 34 deletions

View file

@ -1,21 +1,24 @@
<?php defined('SYSPATH') or die('No direct script access.'); <?php defined('SYSPATH') or die('No direct script access.');
/** /**
* The generate task provides an easy way to create migration files * The new task provides an easy way to create migration files
* *
* Available config options are: * Available config options are:
* *
* --group=path/to/migration/group * --group=group_name
* *
* This is a required config option, use it specify in which group the * This is a required config option, use it specify in which group the
* migration should be stored. Due to the nature of the cascading filesystem * migration should be stored. Migrations are stored in a `migrations`
* minion doesn't automatically know where a migration is stored so make sure * directory followed by the group name specified. By default, the `migrations`
* you pass in the full path to your migrations folder, e.g. * directory is created in `APPPATH` but that can be changed with `--location`
* *
* # The group of the migrations folder is modules/myapp/migrations/myapp/ * --location=modules/auth
* --group=modules/myapp/migrations/myapp/
* *
* On nix based systems you should be able to tab complete the path * Specified the path of the migration (without the `migrations` directory).
* This value is defaulted to `APPPATH`
*
* # The migration will be created in `modules/myapp/migrations/myapp/`
* --group=myapp --location=modules/myapp
* *
* --description="Description of migration here" * --description="Description of migration here"
* *
@ -23,11 +26,9 @@
* filename. It is required but can be changed manually later on without * filename. It is required but can be changed manually later on without
* affecting the integrity of the migration. * affecting the integrity of the migration.
* *
* The description will be
*
* @author Matt Button <matthew@sigswitch.com> * @author Matt Button <matthew@sigswitch.com>
*/ */
class Minion_Task_Db_Generate extends Minion_Task class Minion_Task_Migrations_New extends Minion_Task
{ {
/** /**
* A set of config options that this task accepts * A set of config options that this task accepts
@ -49,7 +50,7 @@ class Minion_Task_Db_Generate extends Minion_Task
try try
{ {
$file = $this->generate($config); $file = $this->generate($config);
Minion_CLI::write('Migration generated: '.$file); Minion_CLI::write('Migration generated: '.$file);
} }
catch(ErrorException $e) catch(ErrorException $e)
{ {
@ -57,7 +58,7 @@ class Minion_Task_Db_Generate extends Minion_Task
} }
} }
public function generate($config, $up = null, $down = null) public function generate($config, $up = null, $down = null)
{ {
$defaults = array( $defaults = array(
@ -86,7 +87,7 @@ class Minion_Task_Db_Generate extends Minion_Task
$file = $this->_generate_filename($location, $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/migrations/new/template')
->set('class', $class) ->set('class', $class)
->set('description', $description) ->set('description', $description)
->set('up', $up) ->set('up', $up)

View file

@ -1,21 +1,21 @@
<?php defined('SYSPATH') or die('No direct script access.'); <?php defined('SYSPATH') or die('No direct script access.');
/** /**
* The Migrate task compares the current version of the database with the target * The Run task compares the current version of the database with the target
* version and then executes the necessary commands to bring the database up to * version and then executes the necessary commands to bring the database up to
* date * date
* *
* Available config options are: * Available config options are:
* *
* --migrate-down * --down
* *
* Migrate the group(s) down * Migrate the group(s) down
* *
* --migrate-up * --up
* *
* Migrate the group(s) up * Migrate the group(s) up
* *
* --migrate-to=(timestamp|+up_migrations|down_migrations) * --to=(timestamp|+up_migrations|down_migrations)
* *
* Migrate to a specific timestamp, or up $up_migrations, or down $down_migrations * Migrate to a specific timestamp, or up $up_migrations, or down $down_migrations
* *
@ -27,24 +27,24 @@
* *
* --groups=group[,group2[,group3...]] * --groups=group[,group2[,group3...]]
* *
* A list of groups that will be used to source migration files. By default * A list of groups that will be used to source migration files. By default
* migrations will be loaded from all available groups. * migrations will be loaded from all available groups.
* *
* Note, only --migrate-up and --migrate-down can be used with --groups * Note, only --up and --down can be used with --groups
* *
* --dry-run * --dry-run
* *
* No value taken, if this is specified then instead of executing the SQL it * No value taken, if this is specified then instead of executing the SQL it
* will be printed to the console * will be printed to the console
* *
* --quiet * --quiet
* *
* Suppress all unnecessary output. If --dry-run is enabled then only dry run * Suppress all unnecessary output. If --dry-run is enabled then only dry run
* SQL will be output * SQL will be output
* *
* @author Matt Button <matthew@sigswitch.com> * @author Matt Button <matthew@sigswitch.com>
*/ */
class Minion_Task_Db_Migrate extends Minion_Task class Minion_Task_Migrations_Run extends Minion_Task
{ {
/** /**
* A set of config options that this task accepts * A set of config options that this task accepts
@ -53,9 +53,9 @@ class Minion_Task_Db_Migrate extends Minion_Task
protected $_config = array( protected $_config = array(
'group', 'group',
'groups', 'groups',
'migrate-up', 'up',
'migrate-down', 'down',
'migrate-to', 'to',
'dry-run', 'dry-run',
'quiet' 'quiet'
); );
@ -70,12 +70,12 @@ class Minion_Task_Db_Migrate extends Minion_Task
$k_config = Kohana::$config->load('minion/migration'); $k_config = Kohana::$config->load('minion/migration');
$groups = Arr::get($config, 'group', Arr::get($config, 'groups', NULL)); $groups = Arr::get($config, 'group', Arr::get($config, 'groups', NULL));
$target = Arr::get($config, 'migrate-to', NULL); $target = Arr::get($config, 'to', NULL);
$dry_run = array_key_exists('dry-run', $config); $dry_run = array_key_exists('dry-run', $config);
$quiet = array_key_exists('quiet', $config); $quiet = array_key_exists('quiet', $config);
$up = array_key_exists('migrate-up', $config); $up = array_key_exists('up', $config);
$down = array_key_exists('migrate-down', $config); $down = array_key_exists('down', $config);
$groups = $this->_parse_groups($groups); $groups = $this->_parse_groups($groups);
@ -110,12 +110,12 @@ class Minion_Task_Db_Migrate extends Minion_Task
} }
catch(Minion_Migration_Exception $e) catch(Minion_Migration_Exception $e)
{ {
return View::factory('minion/task/db/migrate/exception') return View::factory('minion/task/migrations/run/exception')
->set('migration', $e->get_migration()) ->set('migration', $e->get_migration())
->set('error', $e->getMessage()); ->set('error', $e->getMessage());
} }
$view = View::factory('minion/task/db/migrate') $view = View::factory('minion/task/migrations/run')
->set('dry_run', $dry_run) ->set('dry_run', $dry_run)
->set('quiet', $quiet) ->set('quiet', $quiet)
->set('dry_run_sql', $manager->get_dry_run_sql()) ->set('dry_run_sql', $manager->get_dry_run_sql())

View file

@ -7,7 +7,7 @@
* *
* @author Matt Button <matthew@sigswitch.com> * @author Matt Button <matthew@sigswitch.com>
*/ */
class Minion_Task_Db_Status extends Minion_Task { class Minion_Task_Migrations_Status extends Minion_Task {
/** /**
* Execute the task * Execute the task
@ -19,7 +19,7 @@ class Minion_Task_Db_Status extends Minion_Task {
$db = Database::instance(); $db = Database::instance();
$model = new Model_Minion_Migration($db); $model = new Model_Minion_Migration($db);
$view = new View('minion/task/db/status'); $view = new View('minion/task/migrations/status');
$view->groups = $model->get_group_statuses(); $view->groups = $model->get_group_statuses();