I'm using Laravel's schema builder with mysql to make a unique column. But when I use the unique method it is case insensitive. I need it to be case sensitive. How can I do that?
Schema:
Schema::create('item', function (Blueprint $table) {
$table->increments('id');
$table->string('key')->unique();
$table->timestamps();
});
First entry into database:
$i = new Item;
$i->key = "Random_Key";
$i->save();
Second entry into database (returns duplicate entry error):
$i = new Item;
$i->key = "random_key";
$i->save();
utf8_bin
as the collatation, but when I migrated the tables it won't change the collation. I have to go in to the database and manually change the collation. I found a solution to this though. All you have to do is something like this...$cs = $table->string('key')->unique();
then you need to do the following...$cs->collation = 'utf8_bin';
– Sisco