我第一次使用yii2,我想嘗試yii遷移。 問題: 我創建遷移文件,Yii2遷移問題
php yii migrate/create new_table
文件被創建。然後我將新的表格細節輸入到遷移文件中。 當我運行php yii migrate
我有錯誤
Exception 'ReflectionException' with message 'Class db does not exist'
什麼問題?
in /var/www/yii2.uz/vendor/yiisoft/yii2/di/Container.php:415
我console/config/main.php
:
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'components' => [
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
],
'params' => $params,
];
和我的移民文件:
<?php use yii\db\Schema;
use yii\db\Migration;
class m150727_125205_new_table extends Migration
{
public function up()
{
$this->createTable('test',[
'id'=> Schema::TYPE_PK,
'name'=> Schema::TYPE_STRING
]);
}
public function down()
{
echo "m150727_125205_new_table cannot be reverted.\n";
return false;
}
請添加創建的遷移內容和控制檯配置。 – arogachev