Search code examples
laravellaravel-5.5

Laravel 5.5 set size of integer fields in migration file


I am new to laravel.

Now i am using the migrate command to make a table, but the length of the filed is not applicable. Laravel does not provide this option. ?

Below is my codes:

$table->increments('id')->length(11);
$table->dateTime('created_time');
$table->integer('bank_id')->length(11);
$table->tinyInteger('is_black')->length(1);

The length of the field is_black should be 1, but it is actually being generated as 4. How can I solve this problem ?

Any suggestion or advice would be appreciated.

Thank you in advance


Solution

  • You can't do this, but you can use different types of integer:

    $table->bigInteger()
    $table->mediumInteger()
    $table->integer()
    $table->smallInteger()
    $table->tinyInteger()
    

    https://laravel.com/docs/5.5/migrations#columns