3

I want to max the size of the row description. I already set size to 10240 but still it shows error. how to store data in this column because i have to save large amount of data

 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();
    });
}

ERROR I GET

 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

escription, updated_at, created_at`)

1 Answers1

7

if string is long you can use longtext

  $table->longText('description')

The longText method creates a LONGTEXT equivalent column:

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

John Lobo
  • 14,355
  • 2
  • 10
  • 20