【问题标题】:Laravel 8: Migrations how can i add string that is more than 1k characters?Laravel 8:迁移如何添加超过 1k 个字符的字符串?
【发布时间】:2021-09-04 18:41:39
【问题描述】:

大家好,我有这个迁移吗?我希望表体的字符串最多 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();
    });
}

【问题讨论】:

    标签: laravel eloquent migration laravel-8


    【解决方案1】:

    你可以使用longText

    $table->longText('body');
    

    longText 方法创建一个 LONGTEXT 等效列:

    参考:https://laravel.com/docs/8.x/migrations#column-method-longText

    【讨论】:

      猜你喜欢
      • 2018-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-13
      • 2021-05-19
      • 2018-12-31
      • 2020-12-06
      • 2017-10-28
      相关资源
      最近更新 更多