Petro Gromovo
Petro Gromovo

Reputation: 2243

How in migration to change type of field?

In Laravel 5.7 I created tiny field with rule

$table->tinyInteger('renewal_raise_invoice_before')->unsigned()->nullable()->after('renewal_raise_invoice_pre_pay');

But it appears that I need a bigger range. Which is the correct way to change its type to smallInteger?

Upvotes: 1

Views: 71

Answers (2)

Eliecer
Eliecer

Reputation: 81

In case you ran into some mysql issues as I ran before with 5.7 & 5.8 and MySql 8 you can do RAW queries in the migration

Schema::table('table_name',function (Blueprint $table){

  DB::statement('ALTER TABLE table_name MODIFY COLUMN renewal_raise_invoice_before smallint UNSIGNED NULL');

}

Upvotes: 1

Emil Georgiev
Emil Georgiev

Reputation: 528

Make new migration with:

Schema::table('sometable',function (Blueprint $table){
        $table->smallInteger('renewal_raise_invoice_before')->unsigned()->nullable()->change();
    });

Upvotes: 1

Related Questions