Laravel Artisan Migrate 不创建表
Laravel Artisan Migrate Not Creating Tables
我已经按照教程 (here) 设置了我的应用程序。然后我尝试复制这些步骤来创建更多 tables,所以我 运行 在终端中输入了一些命令,例如:
php artisan migrate:make create_generalUserInfo_table
然后在create_generalUserInfo_table文件中我添加了:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateGeneralUserInfoTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('generalUserInfo', function($table){
$table->increments('id');
$table->integer('user_id');
$table->string('firstname', 100);
$table->string('lastname', 100);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('generalUserInfo');
}
}
然后回到终端 I 运行:
php artisan migrate:refresh
正在添加 mig运行ts,但 tables 未在 mysql 中创建。已创建初始教程中的用户 table
Migrated: 2015_01_28_055418_create_users_table
Migrated: 2015_01_28_213951_create_imprints_table
Migrated: 2015_01_28_214023_create_generalUserInfo_table
Migrated: 2015_01_28_214103_create_roles_table
Migrated: 2015_01_28_214114_create_role_user_table
Migrated: 2015_01_28_214146_create_comments_table
Migrated: 2015_01_28_214159_create_books_table
尝试更改此行:
Schema::create('generalUserInfo', function($table){
到
Schema::create('generalUserInfo', function(Blueprint $table){
和运行 迁移命令如下:
php artisan migrate
您还应该确保
- 您的迁移 table 没有将那些 table 作为迁移
插入
- 您的数据库凭据正确并指向正确的数据库
我已经按照教程 (here) 设置了我的应用程序。然后我尝试复制这些步骤来创建更多 tables,所以我 运行 在终端中输入了一些命令,例如:
php artisan migrate:make create_generalUserInfo_table
然后在create_generalUserInfo_table文件中我添加了:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateGeneralUserInfoTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('generalUserInfo', function($table){
$table->increments('id');
$table->integer('user_id');
$table->string('firstname', 100);
$table->string('lastname', 100);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('generalUserInfo');
}
}
然后回到终端 I 运行:
php artisan migrate:refresh
正在添加 mig运行ts,但 tables 未在 mysql 中创建。已创建初始教程中的用户 table
Migrated: 2015_01_28_055418_create_users_table
Migrated: 2015_01_28_213951_create_imprints_table
Migrated: 2015_01_28_214023_create_generalUserInfo_table
Migrated: 2015_01_28_214103_create_roles_table
Migrated: 2015_01_28_214114_create_role_user_table
Migrated: 2015_01_28_214146_create_comments_table
Migrated: 2015_01_28_214159_create_books_table
尝试更改此行:
Schema::create('generalUserInfo', function($table){
到
Schema::create('generalUserInfo', function(Blueprint $table){
和运行 迁移命令如下:
php artisan migrate
您还应该确保
- 您的迁移 table 没有将那些 table 作为迁移 插入
- 您的数据库凭据正确并指向正确的数据库