Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a tiny integer column with custom size in Laravel migration

How can I add tiny integer column using laravel migration to MySQL? I thought this code

$table->addColumn('tinyInteger', 'birth_day', ['lenght' => 2]);

But it creates TINYINT(4) column. I don't know how I can solve this problem. Please don't ask me why a day only, not full date. It is a business logic of the app.

like image 729
Lukas Pierce Avatar asked Oct 18 '22 07:10

Lukas Pierce


1 Answers

I solve my problem by pure sql

DB::statement("ALTER TABLE `users` 
ADD `birth_day` TINYINT(2) DEFAULT NULL AFTER `lastname`");
like image 195
Lukas Pierce Avatar answered Oct 21 '22 07:10

Lukas Pierce