From 166465ec7a7da381a7379b8b37886996c5bc9b92 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Tue, 17 Jun 2014 18:00:22 +0300 Subject: [PATCH] `MigrationInterface` extracted --- .../controllers/BaseMigrateController.php | 3 +- framework/db/Migration.php | 3 +- framework/db/MigrationInterface.php | 35 +++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 framework/db/MigrationInterface.php diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 1acd76df8d..85c1e6e475 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -16,7 +16,6 @@ use yii\helpers\FileHelper; * BaseMigrateController is base class for migrate controllers. * * @author Qiang Xue - * @author Klimov Paul * @since 2.0 */ abstract class BaseMigrateController extends Controller @@ -528,7 +527,7 @@ abstract class BaseMigrateController extends Controller /** * Creates a new migration instance. * @param string $class the migration class name - * @return \yii\db\Migration the migration instance + * @return \yii\db\MigrationInterface the migration instance */ protected function createMigration($class) { diff --git a/framework/db/Migration.php b/framework/db/Migration.php index 049c4f695e..3533f2489d 100644 --- a/framework/db/Migration.php +++ b/framework/db/Migration.php @@ -8,6 +8,7 @@ namespace yii\db; use yii\di\Instance; +use \yii\base\Component; /** * Migration is the base class for representing a database migration. @@ -35,7 +36,7 @@ use yii\di\Instance; * @author Qiang Xue * @since 2.0 */ -class Migration extends \yii\base\Component +class Migration extends Component implements MigrationInterface { /** * @var Connection|string the DB connection object or the application component ID of the DB connection diff --git a/framework/db/MigrationInterface.php b/framework/db/MigrationInterface.php new file mode 100644 index 0000000000..7f69c6499f --- /dev/null +++ b/framework/db/MigrationInterface.php @@ -0,0 +1,35 @@ + + * @since 2.0 + */ +interface MigrationInterface +{ + /** + * This method contains the logic to be executed when applying this migration. + * @return boolean return a false value to indicate the migration fails + * and should not proceed further. All other return values mean the migration succeeds. + */ + public function up(); + + /** + * This method contains the logic to be executed when removing this migration. + * The default implementation throws an exception indicating the migration cannot be removed. + * @return boolean return a false value to indicate the migration fails + * and should not proceed further. All other return values mean the migration succeeds. + */ + public function down(); +} \ No newline at end of file