From 64d87e1be9577f267b801dfe3b5fbe25fcd1a8ab Mon Sep 17 00:00:00 2001 From: Jeremy Bush Date: Thu, 12 May 2011 14:14:09 -0500 Subject: [PATCH 1/3] Add config option to hard prevent migrations before a certain date from running --- classes/minion/migration/manager.php | 9 +++++++++ config/minion/migration.php | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/classes/minion/migration/manager.php b/classes/minion/migration/manager.php index 2c41ead..95abc8f 100644 --- a/classes/minion/migration/manager.php +++ b/classes/minion/migration/manager.php @@ -132,6 +132,15 @@ class Minion_Migration_Manager { foreach ($migrations as $migration) { + if ($method == 'down' AND $migration['timestamp'] <= Kohana::config('minion/migration')->lowest_migration) + { + Minion_CLI::write( + 'You\'ve reached the lowest migration allowed by your config: '.Kohana::config('minion/migration')->lowest_migration, + 'red' + ); + return; + } + $filename = Minion_Migration_Util::get_filename_from_migration($migration); if ( ! ($file = Kohana::find_file('migrations', $filename, FALSE))) diff --git a/config/minion/migration.php b/config/minion/migration.php index 0009457..5f16a12 100644 --- a/config/minion/migration.php +++ b/config/minion/migration.php @@ -6,4 +6,11 @@ return array( 'group_connection' => array( ), + /** + * This specifies which migration should be the "base", in timestamp form. + * This migration will not be run when --migrate-down is called + * + * NULL means all migrations will run + */ + 'lowest_migration' => NULL, ); From e6cdf3ce32209890c1324db9d6f3543879f0730a Mon Sep 17 00:00:00 2001 From: Jeremy Bush Date: Thu, 12 May 2011 14:23:15 -0500 Subject: [PATCH 2/3] Fix bad variable call, Fixes #15 --- classes/minion/migration/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/minion/migration/manager.php b/classes/minion/migration/manager.php index 95abc8f..386688e 100644 --- a/classes/minion/migration/manager.php +++ b/classes/minion/migration/manager.php @@ -173,7 +173,7 @@ class Minion_Migration_Manager { if ($this->_dry_run) { - $this->_dry_run_sql[$path][$migration['timestamp']] = $db->reset_query_stack(); + $this->_dry_run_sql[$migration['group']][$migration['timestamp']] = $db->reset_query_stack(); } else { From b55a258760beaaff322ee4bd634eb3a383ee51c9 Mon Sep 17 00:00:00 2001 From: Jeremy Bush Date: Thu, 12 May 2011 14:52:00 -0500 Subject: [PATCH 3/3] Fix bug where migrations to +/- would not work properly. Fixes #16 --- classes/model/minion/migration.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/classes/model/minion/migration.php b/classes/model/minion/migration.php index 0d505f1..d90c15f 100644 --- a/classes/model/minion/migration.php +++ b/classes/model/minion/migration.php @@ -444,6 +444,12 @@ class Model_Minion_Migration extends Model return array(NULL, $up); } - return array((string) $query->execute($this->_db)->get('timestamp'), $up); + // Seek to the requested row + for ($i = 0; $i < $amount - 1; $i++) + { + $results->next(); + } + + return array((string) $results->get('timestamp'), $up); } }