mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
MigrationInterface extracted
This commit is contained in:
@ -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)
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
35
framework/db/MigrationInterface.php
Normal file
35
framework/db/MigrationInterface.php
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user