Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 70 lines (63 sloc) 1.725 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<?php
/**
* A migration task is a build task that is reversible.
*
* <b>Creating Migration Tasks</b>
*
* To create your own migration task all you need to do is define your own subclass of MigrationTask and define the following functions
*
* <i>mysite/code/MyMigrationTask.php</i>
*
* <code>
* class MyMigrationTask extends BuildTask {
*
* protected $title = "My Database Migrations"; // title of the script
* protected $description = "Description"; // description of what it does
*
* function run($request) {
* if ($request->param('Direction') == 'down') {
* $this->down();
* } else {
* $this->up();
* }
* }
*
* function up() {
* // do something when going from old -> new
* }
*
* function down() {
* // do something when going from new -> old
* }
* }
* </code>
*
* <b>Running Migration Tasks</b>
* To run any tasks you can find them under the dev/ namespace. To run the above script you would need to run
* the following and note - Either the site has to be in [devmode](debugging) or you need to add ?isDev=1 to the URL
*
* <code>
* // url to visit if in dev mode.
* http://www.yoursite.com/dev/tasks/MyMigrationTask
*
* // url if you are in live mode but need to run this
* http://www.yoursite.com/dev/tasks/MyMigrationTask?isDev=1
* </code>
*
* @package sapphire
* @subpackage dev
*/
class MigrationTask extends BuildTask {

protected $title = "Database Migrations";

protected $description = "Provide atomic database changes (not implemented yet)";

function run($request) {
if ($request->param('Direction') == 'down') {
$this->down();
} else {
$this->up();
}
}

function up() {}

function down() {}

}

?>
Something went wrong with that request. Please try again.