Search code examples
phpyii2migrationdatabase-migrationyii2-advanced-app

Yii2 migrate Setting unknown property: yii\caching\FileCache::backuprestore


I know how the migrate works, and have created migrations files before, so I created my migrate file like this:

php yii migrate/create implants_type

it gives me:

<?php

use yii\db\Migration;

class m180403_081742_implants_type extends Migration
{
    public function up()
    {

    }

    public function down()
    {
        echo "m180403_081742_implants_type cannot be reverted.\n";

        return false;
    } 

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}

then

php yii migrate/create create_implants_type_table

and I updated the file that generated like this:

<?php

use yii\db\Migration;

class m180403_081750_create_implants_type_table extends Migration
{
    public function up()
    {
        $this->createTable('implants_type_table', [
            'id' => $this->primaryKey(),
            'implants_name'=>$this->string(),

        ]);
    }

    public function down()
    {
        $this->dropTable('implants_type_table');
    }
}

then I used

./yii migrate

but an error occurred:

Exception 'yii\base\UnknownPropertyException' with message 'Setting unknown property: yii\caching\FileCache::backuprestore'

I updated my composer now, and the problem still exists.


Solution

  • Seems you have improperly configured cache component. Double-check your console configuration: search backuprestore in your project end remove this setting from configuration - there is no such property in official cache components, so you probably messed up something.

    This is probably unrelated to migrations - db component just tries to use cache component to cache DB schema, which triggers this error.