Laravel 4 - Artisan SQLSTATE Error [42000]

I am trying to create a new migration for my users table, I have the following schema:

        Schema::create('users', function($t) {
            $t->increments('id');
            $t->string('username', 16);
            $t->string('password', 64);
            $t->integer('role', 64);
            $t->timestamps();
    });

When I try to run php artisan from the terminal, I get the following error:

[Exception]
SQLSTATE [42000]: Syntax error or access violation: 1075 The definition of the table is incorrect; there can be only one automatic column, and it should be defined as a key (SQL: create table users( idint unsigne d not null auto_increment primary key, usernamevarchar (16) not null, passwordvarchar (64) no t null, roleint not null auto_increment primary key, created_attimestamp default 0 not null, updated_attimestamp default 0 not null)) (Bindings: array (
))

- "role", , .

.

+5
3

integer - .

public function integer($column, $autoIncrement = false, $unsigned = false)

https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Schema/Blueprint.php#L510

+13
$t->integer('role', false);

.

0

The integer length attribute is not allowed. Remove it and try.

0
source

All Articles