I do not apply migrations. I enter the php yii migrate
command and then the error comes out:
[email protected] [~ / 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 /valar/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- & gt; __ construct ('m180601_153539 _...')
# 1 /var/www/u0498223/public_html/coinfactory.pw/vendor/coinfact/yii2/di/container.php(364): Yii \ di \ Container- & GT; GetDependencies ('M180601_153539 _...')
# 2 /Var/www/u0498223/public_html/coinfactory.pw/vendor/coinfact/yii2/di/container.php(156): Yii \ di \ Container- & gt; build ('M180601_153539 _...', Array, Array )
# 3 /Var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/baseyi.php(349): Yii \ di \ Container- & GT; 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/Siisoft/Yii2/console/controllers/basemigrateController.php(724): Yii \ Console \ Controllers \ MigrateController- & gt; CreateMigration ('M180601_153539 _... )
# 6 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(199): yii \ console \ controllers \ BaseMigrateController- & gt; migrateUp ( 'm180601_153539 _...' )
# 7 [INTERNAL FUNCTION]: Yii \ Console \ Controllers \ BasemigrateController- & gt; 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- & gt; RunWithParams (Array)
# 10 /Var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/controller.php(148): Yii \ Base \ Controller- & GT; RunAction ('', Array)
# 11 /Var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/Base/Module.php(528): Yii \ Console \ Controller- & GT; RunAction ('', Array)
# 12 /Var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/application.php(180): Yii \ Base \ Module- & gt; runaction ('Migrate', Array)
# 13 /Var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/console/application.php(147): Yii \ Console \ Application- & gt; RunAction ('Migrate', Array)
# 14/1 /var/www/u0498223/public_html/coinfactory.pw/vendor/yiisoft/yii2/Base/application.php(386): Yii \ Console \ Application- & GT; HandlereQuest (Object (Yii \ Console \ Request))
# 15 /Var/www/u0498223/public_html/coinfactory.pw/yii(20): Yii \ Base \ Application- & gt; Run ()
# 16 {Main}
m180601_153539_create_user_table.php
& lt;? 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- & gt; db- & gt; drivename === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-The-Difference-Between-UnF8-General-Ci-D-UF8-Unicode-ci.
$ TableOptions = 'Character Set UTF8 Collate UTF8_Unicode_ci Engine = Innodb';
}
$ this- & gt; CreateTable ('{{% user}}', [
'id' = & gt; $ this- & gt; primarykey (),
'username' = & gt; $ this- & gt; string () - & gt; notnull () - & gt; unique (),
'auth_key' = & gt; $ this- & gt; string (32) - & gt; notnull (),
'password_hash' = & gt; $ this- & gt; string () - & gt; notnull (),
'password_reset_token' = & gt; $ this- & gt; string () - & gt; unique (),
'email' = & gt; $ this- & gt; string () - & gt; notnull () - & gt; unique (),
'Created_at' = & gt; $ this- & gt; integer () - & gt; notnull (),
'Updated_at' = & gt; $ this- & gt; integer () - & gt; notnull (),
], $ tableoptions);
}
Public Function Down ()
{
$ this- & gt; drptable ('{{% user}}');
}
}
console.php
& lt;? php
$ Params = Require (__ dir__. '/params.php');
$ DB = Require (__ dir__. '/db.php');
$ config = [
'id' = & gt; 'Basic-Console',
'Basepath' = & gt; Dirname (__ Dir__),
'bootstrap' = & gt; ['Log'],
'ControllerNamespace' = & gt; 'App \ Commands',
'Components' = & gt; [
'cache' = & gt; [
'Class' = & gt; 'Yii \ Caching \ FileCache',
],
'log' = & gt; [
'targets' = & gt; [
[
'Class' = & gt; 'Yii \ Log \ Filetarget',
'levels' = & gt; ['Error', 'Warning'],
],
],
],
'db' = & gt; $ db,
],
'Params' = & gt; $ params,
/ *
'Controllermap' = & gt; [
'Fixture' = & gt; [// Fixture Generation Command Line.
'Class' = & gt; 'Yii \ Faker \ FixtureController',
],
],
* /
];
db.php
& lt;? php
Return [
'Class' = & gt; 'Yii \ db \ Connection',
'dsn' = & gt; 'MySQL: host = localhost; dbname = u0498223_coinfactory',
'username' = & gt; 'u0498223_coin',
'password' = & gt; '60592Swallow',
'charset' = & gt; 'UTF8',
'TablePrefix' = & gt; 'pref_',
'enableschemacache' = & gt; True
'EnableQueryCache' = & gt; True
];
What could be the problem?
Answer 1, Authority 100%
Do you have a migration name m180601_153539_create_user_table
, and class m170903_114309_create_user_table
. Rename the file name and migration class coincided.
Since the names of different migration cannot find a class with the desired name. Be careful when copying migrations. I never copy the names of the migration classes, only the table code.