我正在尝试使用 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.php
for log_requests
table.
...然后是以下脚本
public function up()
{
Schema::table('log_requests', function (Blueprint $table) {
$table->longText('request')->nullable()->change();
$table->longText('response')->nullable()->change();
});
}
但它并没有改变列的数据类型。有人可以指导我吗?我哪里错了,我可以修复它吗?谢谢。
EDITED
在评论中请求迁移后,我添加了迁移脚本:
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();
});
}
只需更改列注释即可,例如:
$table->mediumText('myColumn')->comment(' ')->change(); // up
$table->text('myColumn')->comment('')->change(); // down
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)