Commit 166465ec by Klimov Paul

`MigrationInterface` extracted

parent 6cc1310a
...@@ -16,7 +16,6 @@ use yii\helpers\FileHelper; ...@@ -16,7 +16,6 @@ use yii\helpers\FileHelper;
* BaseMigrateController is base class for migrate controllers. * BaseMigrateController is base class for migrate controllers.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @author Klimov Paul <klimov@zfort.com>
* @since 2.0 * @since 2.0
*/ */
abstract class BaseMigrateController extends Controller abstract class BaseMigrateController extends Controller
...@@ -528,7 +527,7 @@ abstract class BaseMigrateController extends Controller ...@@ -528,7 +527,7 @@ abstract class BaseMigrateController extends Controller
/** /**
* Creates a new migration instance. * Creates a new migration instance.
* @param string $class the migration class name * @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) protected function createMigration($class)
{ {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace yii\db; namespace yii\db;
use yii\di\Instance; use yii\di\Instance;
use \yii\base\Component;
/** /**
* Migration is the base class for representing a database migration. * Migration is the base class for representing a database migration.
...@@ -35,7 +36,7 @@ use yii\di\Instance; ...@@ -35,7 +36,7 @@ use yii\di\Instance;
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @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 * @var Connection|string the DB connection object or the application component ID of the DB connection
......
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\db;
/**
* The MigrationInterface defines the minimum set of methods to be implemented by a database migration.
*
* Each migration class should provide the [[up()]] method containing the logic for "upgrading" the database
* and the [[down()]] method for the "downgrading" logic.
*
* @author Klimov Paul <klimov@zfort.com>
* @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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment