How7oHow7o
  • Home
  • Tools
    • All Tools
    • Image Tools
    • Text & String Tools
    • Video Tools
    • Developer Tools
    • PDF Tools
    • Calculators & More
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: Laravel Migration Column Types — Cheat Sheet
Share
Notification Show More
Font ResizerAa
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
    • All Tools
    • Image Tools
    • Text & String Tools
    • Video Tools
    • Developer Tools
    • PDF Tools
    • Calculators & More
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Web Development > Laravel Migration Column Types — Cheat Sheet
Web Development

Laravel Migration Column Types — Cheat Sheet

how7o
By how7o
Last updated: May 23, 2026
5 Min Read
Laravel migration column types cheat sheet
SHARE

Laravel’s schema builder lets you declare column types with a fluent API. Below is a reference cheat sheet of the most-used methods on the Blueprint object — what they create, when to use them, and the modifiers (nullable, default, unsigned) that apply to most types.

Contents
  • IDs and timestamps
  • Strings and text
  • Numbers
  • Dates and times
  • Booleans, enums, binary
  • Foreign keys (modern form)
  • Column modifiers
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-05-17 on Laravel 11. Originally published 2022-09-11, rewritten and updated 2026-05-17.

IDs and timestamps

$table->id();                       // unsigned BIGINT auto-increment primary key, named "id"
$table->bigIncrements('id');        // explicit form of id()
$table->increments('id');           // unsigned INT auto-increment primary key
$table->uuid('id')->primary();      // UUID primary key

$table->timestamps();               // adds created_at + updated_at (TIMESTAMP)
$table->timestampsTz();             // TIMESTAMP WITH TIME ZONE (PostgreSQL-aware)
$table->nullableTimestamps();       // same as timestamps(), but nullable
$table->softDeletes();              // adds deleted_at (nullable TIMESTAMP) for soft deletes
$table->rememberToken();            // adds remember_token VARCHAR(100) NULL
Laravel migration column types — ids, strings, numbers, foreign keys, timestamps, modifiers

Strings and text

$table->string('email');            // VARCHAR(255)
$table->string('name', 100);        // VARCHAR(100)
$table->char('code', 4);            // CHAR(4) — fixed-length

$table->text('body');               // TEXT — up to 64 KB
$table->mediumText('body');         // MEDIUMTEXT — up to 16 MB
$table->longText('body');           // LONGTEXT — up to 4 GB

$table->json('payload');            // JSON column (MySQL 5.7+, MariaDB 10.2+, PostgreSQL)
$table->jsonb('payload');           // JSONB — PostgreSQL only, indexed

Numbers

$table->integer('votes');           // INTEGER
$table->bigInteger('votes');        // BIGINT
$table->smallInteger('votes');      // SMALLINT
$table->tinyInteger('votes');       // TINYINT
$table->mediumInteger('count');     // MEDIUMINT

$table->unsignedBigInteger('uid');  // BIGINT UNSIGNED
$table->unsignedInteger('count');   // INT UNSIGNED

$table->decimal('amount', 10, 2);   // DECIMAL(10,2) — money, exact
$table->float('rate');              // FLOAT — approximate
$table->double('coord', 15, 8);     // DOUBLE — high-precision approximate

For money, use decimal — floats accumulate rounding errors. For coordinates and physics, double with high precision.

Dates and times

$table->date('birthday');           // DATE
$table->dateTime('starts_at');      // DATETIME
$table->time('opens_at');           // TIME
$table->timestamp('confirmed_at');  // TIMESTAMP
$table->year('graduated');          // YEAR (MySQL-specific)

Booleans, enums, binary

$table->boolean('is_active');                 // TINYINT(1) on MySQL, native BOOLEAN on PG
$table->enum('status', ['draft', 'live']);    // ENUM — MySQL-specific; consider check constraints instead
$table->binary('data');                       // BLOB

Foreign keys (modern form)

// Recommended — single line
$table->foreignId('user_id')->constrained();

// With ON DELETE cascade
$table->foreignId('post_id')
    ->constrained()
    ->cascadeOnDelete();

// Pointing at a non-conventional column
$table->foreignUuid('account_id')
    ->constrained('accounts', 'uuid')
    ->cascadeOnDelete();

// Polymorphic
$table->morphs('taggable');             // adds taggable_id (BIGINT) + taggable_type (VARCHAR)
$table->nullableMorphs('taggable');     // same, but both nullable

Column modifiers

$table->string('email')->nullable();          // allow NULL
$table->integer('count')->default(0);         // default value
$table->integer('age')->unsigned();           // no negative values
$table->string('slug')->unique();             // UNIQUE constraint
$table->string('email')->index();             // index for searching
$table->text('summary')->after('title');      // place after a specific column (MySQL)
$table->string('note')->comment('Internal'); // attach a column comment

Modifiers chain on any column declaration. For schema changes, $table->string('email')->nullable()->change() alters an existing column.

Frequently asked questions

Should I use id() or bigIncrements('id')?

Same column. $table->id() (Laravel 7+) is the modern shortcut — it creates an auto-incrementing unsigned BIGINT primary key named id. bigIncrements('id') is the explicit form. Either works on every modern Laravel; id() reads cleaner.

Why foreignId() instead of unsignedBigInteger?

$table->foreignId('user_id')->constrained() creates the column and the foreign key constraint in one go. Compared to the old pattern of unsignedBigInteger('user_id') followed by foreign('user_id')->references('id')->on('users'), it’s three lines shorter and reads cleanly. Use it for new code; the old form still works.

What’s the difference between timestamps() and timestampsTz()?

timestamps() creates created_at and updated_at as TIMESTAMP columns (UTC seconds since epoch on MySQL). timestampsTz() uses TIMESTAMP WITH TIME ZONE — supported on PostgreSQL, treated as plain timestamp on MySQL. For multi-region apps where you store local times explicitly, use timestampsTz(). For UTC-everywhere apps, the plain version is fine.

Are tinyInteger, smallInteger, etc. worth the column-size optimization?

On disk yes, in practice rarely. The size difference matters when a column holds billions of rows; under millions, the gain is invisible. Pick the type that matches the value range, not the smallest possible — clarity beats premature optimization. For booleans, boolean() generates the right tiny column for your database.

Related guides

  • How to Add Foreign Keys in Laravel Migration
  • How to Add New Columns to an Existing Table in Laravel Migration
  • How to Change a MySQL Column Data Type Using Migration in Laravel

References

Laravel migrations — column types: laravel.com/docs/migrations#available-column-types. Foreign-key constraints: laravel.com/docs/migrations#foreign-key-constraints.

TAGGED:databaseLaravelphp

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Fix Laravel CSRF token mismatch in DataTables Ajax How to Fix Laravel CSRF Token Mismatch in DataTables Ajax
Next Article Fix DKIM not signing emails in aaPanel How to Fix DKIM Not Signing Emails in aaPanel
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

You Might Also Like

Laravel unknown column CONCAT fix — DB::raw and selectRaw bypass identifier escaping
Web Development

How to Fix “Unknown column ‘CONCAT'” in Laravel

8 Min Read
PHP convert string to uppercase — strtoupper and mb_strtoupper
Web Development

How to Convert a String to Uppercase in PHP

6 Min Read
Comment in a .gitignore file with the # character
Web Development

How to Comment in a .gitignore File

4 Min Read
Fix 409 Conflict error in Laravel (cookies, cache, WAF)
Web Development

How I Fixed the 409 Conflict Error in Laravel (Cookie / Browser / WAF Fix)

7 Min Read
How7oHow7o

Free browser-based tools, prank screens, and step-by-step tech tutorials. No signup, nothing uploaded.

  • Private by design — your files never leave your device
  • Instant — no signup, no install, no waiting
  • Always free — no trials, no watermarks, no paywalls

Tools

  • PDF Editor
  • Image Upscaler
  • JPEG Compressor
  • Password Generator
  • QR Code Generator
  • Video Trimmer
  • See all tools →

Pranks

  • Cracked Screen Prank
  • Fake Blue Screen (BSOD)
  • Fake Disk Format
  • Fake Low Battery
  • Fake Virus Scan
  • Fake Windows 10 Update
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?