mercredi 20 février 2019

How to add unique constraint to column with LongText datatype in laravel 5.7

Can i add unique constraint to LongText column in laravel. I mean, for example i have table having body column with LongText datatype, then how i can make it unique.

  $table->LongText('body')->unique();

When i do this it will generate the following SQL error.

   Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'long_questi
on' used in key specification without a key length (SQL: alter table `long_questions` add unique `long_questions_long_question
_unique`(`long_question`))

I need need a solution for this to make a LongText column unique... please give me any suggestion.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire