Skip to content
PHP Ecosystem
Explore

MigrationInterface

API reference › yii › db › MigrationInterface

interfaceyii\db\MigrationInterface
Since2.0
Sourceframework/db/MigrationInterface.php
Implemented by 1 type

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.

MethodDescriptionDefined by
down() abstractThis method contains the logic to be executed when removing this migration.MigrationInterface
up() abstractThis method contains the logic to be executed when applying this migration.MigrationInterface
abstract public function down(): bool

This method contains the logic to be executed when removing this migration.

The default implementation throws an exception indicating the migration cannot be removed.

Returns

bool: Return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

abstract public function up(): bool

This method contains the logic to be executed when applying this migration.

Returns

bool: Return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.