у меня не применяются миграции. Ввожу команду php yii migrate
и тут выходит ошибка:
u0498223@u0498223.cp.regruhosting.ru [~/public_html/coinfactory.pw]# php yii migrate
Yii Migration Tool (based on Yii v2.0.15.1)
Total 3 new migrations to be applied:
m180601_153539_create_user_table
m180604_124322_drop_user_table
m180604_124811_create_user_table
Apply the above migrations? (yes|no) [no]:yes
*** applying m180601_153539_create_user_table
Exception 'ReflectionException' with message 'Class m180601_153539_create_user_table does not exist'
in /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/di/Container.php:428
Stack trace:
#0 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/di/Container.php(428): ReflectionClass->__construct('m180601_153539_...')
#1 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/di/Container.php(364): yii\di\Container->getDependencies('m180601_153539_...')
#2 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('m180601_153539_...', Array, Array)
#3 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get('m180601_153539_...', Array, Array)
#4 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/controllers/MigrateController.php(202): yii\BaseYii::createObject(Array)
#5 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(724): yii\console\controllers\MigrateController->createMigration('m180601_153539_...')
#6 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(199): yii\console\controllers\BaseMigrateController->migrateUp('m180601_153539_...')
#7 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#8 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('', Array)
#11 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#12 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#13 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#14 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#15 /var/www/u0498223/public_html/coinfactory.pw/yii(20): yii\base\Application->run()
#16 {main}
m180601_153539_create_user_table.php
<?php
use yii\db\Migration;
/**
* Handles the creation of table `user`.
*/
class m180601_153539_create_user_table extends Migration
{
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%user}}', [
'id' => $this->primaryKey(),
'username' => $this->string()->notNull()->unique(),
'auth_key' => $this->string(32)->notNull(),
'password_hash' => $this->string()->notNull(),
'password_reset_token' => $this->string()->unique(),
'email' => $this->string()->notNull()->unique(),
'created_at' => $this->integer()->notNull(),
'updated_at' => $this->integer()->notNull(),
], $tableOptions);
}
public function down()
{
$this->dropTable('{{%user}}');
}
}
console.php
<?php
$params = require(__DIR__ . '/params.php');
$db = require(__DIR__ . '/db.php');
$config = [
'id' => 'basic-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'app\commands',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
],
'params' => $params,
/*
'controllerMap' => [
'fixture' => [ // Fixture generation command line.
'class' => 'yii\faker\FixtureController',
],
],
*/
];
db.php
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=u0498223_coinfactory',
'username' => 'u0498223_coin',
'password' => '60592swallow',
'charset' => 'utf8',
'tablePrefix' => 'pref_',
'enableSchemaCache' => true,
'enableQueryCache' => true,
];
В чём может быть проблема?
m180601_153539_create_user_table
покажите файл в котором описывается эта миграция и файл конфигурации подключения к бд для консольного приложения. Подобный вопрос уже был на англ. SO.