How can I modify a migration in Laravel?

前端 未结 5 636
眼角桃花
眼角桃花 2020-12-29 23:49

I\'m trying to modify a existing migration. Here is my current migration class:

class CreateLogForUserTable extends Migration
{
    public function up()
             


        
5条回答
  •  情话喂你
    2020-12-30 00:18

    You can use the change method, it allows you to modify some existing column types to a new type or modify the column's attributes.

    For example modify a column to be nullable:

    Schema::table('log_for_user', function ($table) {
        $table->string('error_message')->nullable()->change();
    });
    

    But first of all you'll need the doctrine/dbal package

    composer require doctrine/dbal
    

提交回复
热议问题