/** * Task to build a new migration file * * @return null */ protected function _execute(array $params) { $migrations = new Flexiblemigrations(true); try { $model = ORM::factory('Migration'); } catch (Database_Exception $a) { Minion_CLI::write('Flexible Migrations is not installed. Please Run the migrations.sql script in your mysql server'); exit; } $status = $migrations->generate_migration($params['name']); if ($status == 0) { Minion_CLI::write('Migration ' . $params['name'] . ' was succefully created'); Minion_CLI::write('Please check migrations folder'); } else { Minion_CLI::write('There was an error while creating migration ' . $params['name']); } }
/** * Task to rollback last executed migration * * @return null */ protected function _execute(array $params) { $migrations = new Flexiblemigrations(true); try { $model = ORM::factory('Migration'); } catch (Database_Exception $a) { Minion_CLI::write('Flexible Migrations is not installed. Please Run the migrations.sql script in your mysql server'); exit; } $messages = $migrations->rollback(); if (empty($messages)) { Minion_CLI::write("There's no migration to rollback"); } else { foreach ($messages as $message) { if (key($message) == 0) { Minion_CLI::write($message[0]); } else { Minion_CLI::write($message[key($message)]); Minion_CLI::write("ERROR"); } } } }
<?php defined('SYSPATH') or die('No direct script access.'); $migrations_class = new Flexiblemigrations(true); $migrations_config = $migrations_class->get_config(); // Enabling the Userguide module from my Module // Kohana::modules(Kohana::modules() + array('userguide' => MODPATH.'userguide')); //If web frontend is enabled, set the routes if ($migrations_config['web_frontend']) { Route::set('migrations_route', $migrations_config['web_frontend_route'])->defaults(array('controller' => 'flexiblemigrations', 'action' => 'index')); Route::set('migrations_new', $migrations_config['web_frontend_route'] . '/new')->defaults(array('controller' => 'flexiblemigrations', 'action' => 'new')); Route::set('migrations_create', $migrations_config['web_frontend_route'] . '/create')->defaults(array('controller' => 'flexiblemigrations', 'action' => 'create')); Route::set('migrations_migrate', $migrations_config['web_frontend_route'] . '/migrate')->defaults(array('controller' => 'flexiblemigrations', 'action' => 'migrate')); Route::set('migrations_rollback', $migrations_config['web_frontend_route'] . '/rollback')->defaults(array('controller' => 'flexiblemigrations', 'action' => 'rollback')); }