DEV Community

loading...
Cover image for Ways to declare unsigned columns in the Laravel migrations

Ways to declare unsigned columns in the Laravel migrations

Vishnu Damwala
A human being currently living in India🇮🇳 on Earth. Founder of MeshWorld, a web geek, an industry experienced web developer & tutor/instructor currently lives in Surat City.
Originally published at meshworld.in ・1 min read

Laravel developers love the way it handles relationships between tables by just associating models with each other.

The column which defines the relationship between tables must be of unsigned type.

In this tutorial, we'll see how we can declare columns as unsigned in different ways in Laravel.

You need to import Illuminate\Database\Schema namespace with use keyword.

Using unsignedInteger column types

  $table->unsignedInteger('user_id');

Using only integer column type

  $table->integer('user_id', false, true);

Using integer column type with unsigned column modifier

  $table->integer('user_id')->unsigned();

Read the complete post on our site MeshWorld - Ways to declare unsigned columns in the Laravel migrations

For more, you can check the official documentation for migrations creating-columns page.

Read others post on our site MeshWorld

Happy coding

With ❤️ from 🇮🇳

Discussion (0)