MigrationInterface extracted

This commit is contained in:
Klimov Paul
2014-06-17 18:00:22 +03:00
parent 6cc1310aed
commit 166465ec7a
3 changed files with 38 additions and 3 deletions

View File

@ -16,7 +16,6 @@ use yii\helpers\FileHelper;
* BaseMigrateController is base class for migrate controllers.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Klimov Paul <klimov@zfort.com>
* @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)
{

View File

@ -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 <qiang.xue@gmail.com>
* @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

View File

@ -0,0 +1,35 @@
<?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();
}