php - Laravel Artisan Migrate 不创建表

标签 php mysql laravel laravel-4 laravel-artisan

我已按照教程 ( here ) 设置我的应用程序。然后我尝试复制这些步骤来创建更多表,所以我在终端中运行了一些命令,例如:

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');
    }

}

然后回到终端我跑了:

php artisan migrate:refresh

它正在添加移民,但没有在 mysql 中创建表。创建了初始教程中的用户表

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

你还应该确保

  • 您的迁移表没有插入那些已迁移的表
  • 您的数据库凭据正确并指向正确的数据库

关于php - Laravel Artisan Migrate 不创建表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28203805/

相关文章:

php - 在 PHP 中将 XSD 模板转换为 XML 实例

php - 对于每个循环不适用于多个变量

sql - 选择从查询中检索列名的列

php - 在php中添加搜索过滤器

Laravel 5.2 和 Angular 2 CRUD 示例

拉维尔 5 : how to get the paths of all routes?

php - PHP中是否有短路或返回最左边的值?

表单的 PHP 错误

php - 使用 php 在 ajax 中获取错误或成功状态

sqlite - 为什么使用 Laravel 的模式构建器定义的 NOT NULL 数据约束允许在使用 SQLite3 时插入 NULL 值?