Laravel8:迁移如何添加超过1k个字符的字符串?
大家好,我有这个迁移吗?我希望表格正文的字符串最多 1000 个字符。我认为一个字符串的默认字符数是 255。我希望你能帮助我,因为我需要输入 700 多个字符串。谢谢你们
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('body');
$table->string('editedby');
$table->timestamps();
});
}
回答
您可以使用 longText
$table->longText('body');
该longText方法创建一个LONGTEXT等效列:
参考:https : //laravel.com/docs/8.x/migrations#column-method-longText