Uma*_*sit 4 mysql migration database-design laravel
我想最大化行描述的大小。我已经将大小设置为 10240 但它仍然显示错误。如何在此列中存储数据,因为我必须保存大量数据
public function up()
{
Schema::create('final_news', function (Blueprint $table) {
$table->id();
$table->integer('id_newspaper');
$table->string('heading');
$table->string('description', 10240);
$table->timestamps();
});
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'description' at row 1 (SQL: insert into `final_news` (`id_newspaper`, `heading`, `d
Run Code Online (Sandbox Code Playgroud)
描述, updated_at , created_at`)
如果字符串很长,您可以使用 longtext
$table->longText('description')
Run Code Online (Sandbox Code Playgroud)
该longText方法创建一个LONGTEXT等效列:
参考:https : //laravel.com/docs/8.x/migrations#column-method-longText