Question

I have created an run the following migration within my brand new Laravel project:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function(Blueprint $table)
        {
            $table->increments('id');

            $table->string('name', 255);
            $table->string('email', 255);
            $table->integer('user_level');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('users');
    }

}

I would have expected it to create a users table with name, email, etc., but what I ended up with was a migration table. What have I done wrong?

Was it helpful?

Solution

Try this

Schema::create('users', function(Blueprint $table){
        table->increments('id');
        $table->string('name', 255);
        $table->string('email', 255);
        $table->integer('user_level');
        $table->timestamps();
});

The migration table is used by laravel to keep track of the migrations and rollbacks you have done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top