【问题标题】:Yii2 migrate Setting unknown property: yii\caching\FileCache::backuprestoreYii2 migrate 设置未知属性:yii\caching\FileCache::backuprestore
【发布时间】:2018-09-12 16:40:21
【问题描述】:

我知道迁移是如何工作的,并且之前已经创建了迁移文件, 所以我像这样创建了我的迁移文件:

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

但发生错误:

异常 'yii\base\UnknownPropertyException' 带有消息 'Setting unknown property: yii\caching\FileCache::backuprestore'

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

【问题讨论】:

  • 你为什么不使用 php yii migrate ?
  • 您编写的迁移没有任何问题。检查缓存配置
  • @mrateb 了解git-scm.com plz!

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


【解决方案1】:

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

这可能与迁移无关 - db 组件只是尝试使用 cache 组件缓存 DB 架构,这会触发此错误。

【讨论】:

  • 没错,在 Main.php 中的公共文件夹 ` 'backuprestore' => [ 'class' => '\oe\modules\backuprestore\Module'], `
猜你喜欢
  • 2017-07-13
  • 2014-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多