Skip to content

Commit

Permalink
Moving the util methods to the model (refs #11)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeelot committed Jul 2, 2011
1 parent 48df2fe commit 307181c
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 148 deletions.
22 changes: 11 additions & 11 deletions classes/minion/migration/manager.php
@@ -1,8 +1,8 @@
<?php defined('SYSPATH') or die('No direct script access.');

/**
* The migration manager is responsible for locating migration files, syncing
* them with the migrations table in the database and selecting any migrations
* The migration manager is responsible for locating migration files, syncing
* them with the migrations table in the database and selecting any migrations
* that need to be executed in order to reach a target version
*
* @author Matt Button <matthew@sigswitch.com>
Expand Down Expand Up @@ -58,7 +58,7 @@ public function __construct(Kohana_Database $db, Model_Minion_Migration $model =

/**
* Set the database connection to be used
*
*
* @param Kohana_Database Database connection
* @return Minion_Migration_Manager
*/
Expand Down Expand Up @@ -96,7 +96,7 @@ public function set_dry_run($dry_run)
}

/**
* Returns a set of queries that would've been executed had dry run not been
* Returns a set of queries that would've been executed had dry run not been
* enabled. If dry run was not enabled, this returns an empty array
*
* @return array SQL Queries
Expand Down Expand Up @@ -141,28 +141,28 @@ public function run_migration($group = array(), $target = TRUE)
return;
}

$filename = Minion_Migration_Util::get_filename_from_migration($migration);
$filename = $this->_model->get_filename_from_migration($migration);

if ( ! ($file = Kohana::find_file('migrations', $filename, FALSE)))
{
throw new Kohana_Exception(
'Cannot load migration :migration (:file)',
'Cannot load migration :migration (:file)',
array(
':migration' => $migration['id'],
':migration' => $migration['id'],
':file' => $filename
)
);
}

$class = Minion_Migration_Util::get_class_from_migration($migration);
$class = $this->_model->get_class_from_migration($migration);

include_once $file;

$instance = new $class($migration);

$db = $this->_get_db_instance($instance->get_database_connection());

try
try
{
$instance->$method($db);
}
Expand Down Expand Up @@ -204,7 +204,7 @@ public function sync_migration_files()
// If this migration has since been deleted
if (isset($installed[$migration]) AND ! isset($available[$migration]))
{
// We should only delete a record of this migration if it does
// We should only delete a record of this migration if it does
// not exist in the "real world"
if ($installed[$migration]['applied'] === '0')
{
Expand All @@ -216,7 +216,7 @@ public function sync_migration_files()
{
$this->_model->add_migration($available[$migration]);
}
// Somebody changed the description of the migration, make sure we
// Somebody changed the description of the migration, make sure we
// update it in the db as we use this to build the filename!
elseif ($installed[$migration]['description'] !== $available[$migration]['description'])
{
Expand Down
124 changes: 0 additions & 124 deletions classes/minion/migration/util.php

This file was deleted.

0 comments on commit 307181c

Please sign in to comment.