0

Error while compiling my database, and not sure what to fix. It didn't gave me the warning for sqlite, but its squawking on mysql.

Schema::create('question', function(Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->softDeletes();
            $table->text('title')->index();
            $table->string('hint')->nullable();
            $table->text('explanation')->nullable();
            $table->string('referencematerial')->nullable();
            $table->string('imagepath')->nullable();
            $table->boolean('published')->default(1);
        });




[Illuminate\Database\QueryException]
  SQLSTATE[42000]: Syntax error or access violation: 1
  170 BLOB/TEXT column 'title' used in key specificati
  on without a key length (SQL: alter table `question`
   add index `question_title_index`(`title`))



  [PDOException]
  SQLSTATE[42000]: Syntax error or access violation: 1
  170 BLOB/TEXT column 'title' used in key specificati
  on without a key length
manshu
  • 1,095
  • 2
  • 13
  • 28

1 Answers1

0

You cannot index TEXT field as index in mysql, see related question

One solution is that you create title as varchar like varchar(200)

Community
  • 1
  • 1
techblu3
  • 170
  • 9