Alex Pelletier
Alex Pelletier

Reputation: 5123

Laravel Artisan Migrate Not Creating Tables

I have followed the tutorial (here) to setup my app. Then I tried to replicate the steps to create more tables, so I ran a few command in the terminal like:

php artisan migrate:make create_generalUserInfo_table

Then in the create_generalUserInfo_table file I added:

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

}

Then Back to terminal I ran:

php artisan migrate:refresh

It is adding the migrants but the tables are not being create in mysql. the Users table from the initial tutorial was created

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

Upvotes: 0

Views: 20128

Answers (1)

baao
baao

Reputation: 73241

Try to change this line:

Schema::create('generalUserInfo', function($table){

to

Schema::create('generalUserInfo', function(Blueprint $table){

and run the migration command like this:

php artisan migrate

You should also make sure that

  • your migration table doesn't have those tables inserted as migrated
  • your database credentials are correct and point to the correct DB

Upvotes: 3

Related Questions