PHP artisan迁移不创建新表
发布时间:2020-12-13 13:32:21 所属栏目:PHP教程 来源:网络整理
导读:我是Laravel的新手,我正在关注Laravel Documentations以及一些教程视频.但是,我在我的本地CMD提示符中运行这个php artisan迁移代码,而不是在phpmyadmin中创建数据库表.在stackoverflow中还有其他几个与此相关的类似主题,但没有解决我的问题.请不要标记此副本
我是Laravel的新手,我正在关注Laravel Documentations以及一些教程视频.但是,我在我的本地CMD提示符中运行这个php artisan迁移代码,而不是在phpmyadmin中创建数据库表.在stackoverflow中还有其他几个与此相关的类似主题,但没有解决我的问题.请不要标记此副本.
好吧,它是这样的.我运行这段代码 php artisan make:migration create_student_table --create=student 并在迁移文件夹中创建新文件,如2016_04_08_061507_create_student_table.php 然后在该文件中我运行此代码 use IlluminateDatabaseSchemaBlueprint; use IlluminateDatabaseMigrationsMigration; class CreateStudentTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('student',function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->string('name',20); $table->string('email',255); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('student'); } } 然后在cmd我运行php artisan migrate但它没有创建学生表.相反,它显示此消息
几天前我使用类似的方法创建了用户表.但是没有创建新的学生表.我在这里遗漏了什么?
这意味着Laravel首先尝试运行users表迁移.如果您正在开发中并且不需要保留数据,则可以删除users表,然后运行php artisan migrate
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |