Created
July 31, 2013 06:14
-
-
Save arnold-almeida/6119741 to your computer and use it in GitHub Desktop.
Shortcut shell to the CakeDC Migrations plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Shortcut shell to the CakeDC Migrations plugin | |
* Plugin : | |
* git submodule add https://github.com/CakeDC/migrations.git app/Plugin/Migrations | |
* Install this file: | |
* app/Console/Command | |
* Usage: | |
* cake migrate [subcommand] [-h] [-v] [-q] | |
* | |
* @author Sime ([email protected]) | |
* @author Arnold ([email protected]) | |
*/ | |
class MigrateShell extends AppShell | |
{ | |
public function main() | |
{ | |
$this->out($this->OptionParser->help()); | |
} | |
public function all() | |
{ | |
$this->dispatchShell('Migrations.migration', 'run', 'all'); | |
} | |
public function generate() | |
{ | |
// Run any existing migrations before, just to be safe | |
$this->all(); | |
$this->dispatchShell('Migrations.migration', 'generate', '-f'); | |
} | |
public function up() | |
{ | |
$this->dispatchShell('Migrations.migration', 'run', 'up'); | |
} | |
public function down() | |
{ | |
$this->dispatchShell('Migrations.migration', 'run', 'down'); | |
} | |
public function reset() | |
{ | |
$this->dispatchShell('Migrations.migration', 'run', 'reset'); | |
} | |
public function getOptionParser() | |
{ | |
$parser = parent::getOptionParser(); | |
$parser->description( | |
'Shortcut shell for the Migration plugin' | |
) | |
->addSubcommand('all', array( | |
'help' => __('To get all pending changes into your database.'))) | |
->addSubcommand('generate', array( | |
'help' => __('Generates a migration file.'))) | |
->addSubcommand('up', array( | |
'help' => __('Upgrade to next version'))) | |
->addSubcommand('down', array( | |
'help' => __('Downgrade to previous version'))) | |
->addSubcommand('reset', array( | |
'help' => __('Reset your database.'))) | |
->addSubcommand('setupbdd', array( | |
'help' => __('Setup the test DB for BDD'))); | |
return $parser; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment