Laravel migration table field's type change

后端 未结 7 1493
难免孤独
难免孤独 2020-12-08 12:45

Following is my file 2015_09_14_051851_create_orders_table.php. And I want to change $table->integer(\'category_id\'); as a string with new migratio

7条回答
  •  鱼传尺愫
    2020-12-08 13:30

    update: 31 Oct 2018, Still usable on laravel 5.7 https://laravel.com/docs/5.7/migrations#modifying-columns

    To make some change to existing db, you can modify column type by using change() in migration.

    This is what you could do

    Schema::table('orders', function ($table) {
        $table->string('category_id')->change();
    });
    

    please note you need to add doctrine/dbal dependency to composer.json for more information you can find it here http://laravel.com/docs/5.1/migrations#modifying-columns

提交回复
热议问题