Yii2 migrate设置未知属性:yii \ caching \ FileCache :: backuprestore

时间:2018-04-03 11:11:40

标签: php yii2 migration database-migration yii2-advanced-app

我知道迁移是如何工作的,之前创建了迁移文件, 所以我创建了我的迁移文件:

php yii migrate/create implants_type
它给了我:

<?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()
    {
    }
    */
}

然后

php yii migrate/create create_implants_type_table

我更新了这样生成的文件:

<?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');
    }
}

然后我用

./yii migrate

但发生错误:

  

例外&#39; yii \ base \ UnknownPropertyException&#39;使用消息&#39;设置未知属性:yii \ caching \ FileCache :: backuprestore&#39;

我现在更新了我的作曲家,问题仍然存在。

1 个答案:

答案 0 :(得分:1)

您似乎未正确配置cache组件。仔细检查您的控制台配置:在项目结束中搜索backuprestore从配置中删除此设置 - 官方缓存组件中没有此类属性,因此您可能搞砸了。

这可能与迁移无关 - db组件只是尝试使用cache组件来缓存数据库模式,从而触发此错误。