Skip to content

Instantly share code, notes, and snippets.

@ollym
Created January 11, 2010 19:21
Show Gist options
  • Save ollym/274500 to your computer and use it in GitHub Desktop.
Save ollym/274500 to your computer and use it in GitHub Desktop.
// Get a recursive array of every model
$models = new RecursiveArrayIterator(Kohana::list_files('classes/model'));
// Loop through each model recursively
foreach (new RecursiveIteratorIterator($models) as $model => $path)
{
// Clean up the model name, and make it relative to the model folder
$model = trim(str_replace(array('classes/model', EXT), '', $model), DIRECTORY_SEPARATOR);
// Replace the directory seperators with underscores
$class = str_replace(DIRECTORY_SEPARATOR, '_', $model);
// Create a new reflection class of the model
$class = new ReflectionClass('model_'.$class);
// Check if the class is instantiable
if ($class->isInstantiable())
{
// If it is we can migrate it
Migration::factory($model, 'sprig')
->sync();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment