Laravel 8: 迁移如何添加超过 1k 个字符的字符串?
Laravel 8: Migrations how can i add string that is more than 1k characters?
大家好,我有这个迁移吗?我想要 table 主体的字符串最多 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
大家好,我有这个迁移吗?我想要 table 主体的字符串最多 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