Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add tinyint to database field in cakephp 3 using migration Plugin?

I am using cakephp 3 migrations plugin to design database. I want to add a status field tinyint with limit as 1 to an field, I have tried the following but nothing adds up.

Attempt 1. (Fails)

$table->addColumn('status', 'smallinteger', [
        'default' => 0,
        'limit' => 1,
        'null' => false,
]);

Attempt 2. (Fails)

$table->addColumn('status', 'tinyint', [
        'default' => 0,
        'limit' => 1,
        'null' => false,
]);

I could not find any documentation for the same may be its there and i am missing something Docs Link

like image 992
valar morghulis Avatar asked Sep 05 '25 02:09

valar morghulis


1 Answers

Adding field type of boolean adds tinyint column of length 1

$table
      ->addColumn('status', 'boolean', [
                'default' => false,
                'null' => false,
            ]);
like image 59
Nabin Nembang Avatar answered Sep 07 '25 17:09

Nabin Nembang