Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

simplenotezy's avatar

Why use tinyInteger over boolean for migrations?

I noticed Taylor uses tinyInteger instead of boolean. Why would he not use the built in boolean?

As seen in create_users_table.php in Spark: $table->tinyInteger('uses_two_factor_auth')->default(0);

0 likes
6 replies
keevitaja's avatar

These datatypes are the same. One is just an alias for another.

spekkionu's avatar

Not all database types have a boolean type.
For example postgres has a boolean type but mysql and sqlite don't.

Because laravel needs to work with multiple database types it just uses an integer with 1 or 0 which is supported in all databases.

1 like
simplenotezy's avatar

But why not use Boolean? It looks cleaner and he built it after all.

pmall's avatar

But why not use Boolean? It looks cleaner and he built it after all.

For example postgres has a boolean type but mysql and sqlite don't.

ohffs's avatar
ohffs
Best Answer
Level 50

I think @canfiax means 'Laravel has a boolean column type which is mapped to a tinyint on mysql, so why didn't Taylor use it?'. The answer being 'No idea - ask Taylor via twitter maybe' :-)

1 like

Please or to participate in this conversation.