如何在 Laravel 5.6 中更改列数据类型?

Imr*_*bas 8 php laravel laravel-5.6

我正在尝试使用 laravel 5.6 更改列数据类型。

我有一个表,其中两列的数据类型为 ,text但我想将其更改为longtext. 我试过以下:

  • 被执行 composer require doctrine/dbal
  • 被执行 composer dump-autoload

...然后2019_12_23_065820_change_response_column_data_type_in_log_requests_table.phplog_requests表创建迁移。

...然后是以下脚本

public function up()
{
    Schema::table('log_requests', function (Blueprint $table) {
        $table->longText('request')->nullable()->change();
        $table->longText('response')->nullable()->change();
    });
}
Run Code Online (Sandbox Code Playgroud)

但它不会改变列的数据类型。有人可以指导我吗?我哪里错了,以便我可以修复它?谢谢你。

已编辑

在评论中请求迁移后,我添加了迁移脚本:

public function up()
{
    Schema::create('log_requests', function (Blueprint $table) {
        $table->increments('id');
        $table->bigInteger('user_id')->nullable()->unsigned();
        $table->string('api_name')->nullable();
        $table->string('url')->nullable();
        $table->string('method')->nullable();
        $table->string('ip_address')->nullable();
        $table->string('status_code')->nullable();
        $table->string('duration')->nullable();
        $table->text('request')->nullable();
        $table->text('response')->nullable();
        $table->timestamps();
    });
}
Run Code Online (Sandbox Code Playgroud)

Imm*_*yti 4

只需更改列注释即可,例如:

$table->mediumText('myColumn')->comment(' ')->change(); // up
$table->text('myColumn')->comment('')->change(); // down
Run Code Online (Sandbox Code Playgroud)