I have a case-insensitive
collation column in my table.
col_name : hash_id, collation : utf8mb4_unicode_ci
I am getting results for yA2JeGs
and YA2JeGs
when I search for former only.
So I need to update the collation to ensure case-sensitivity
for that column.
I tried changing the collation for that column creating a new migration
file:
public function up()
{
Schema::table('product_match_unmatches', function (Blueprint $table) {
$table->string('hash_id')->collate('utf8mb4_bin')->change();
});
}
Also with $table->string('hash_id')->collation('utf8mb4_bin')->change();
Migration runs successfully but the collation remains the same.
How do I do that in laravel?
How to change data type of column in laravel 9 migration ? Step 1 : Install doctrine/dbal package. Step 2 : Generate migration file. Step 3 : Open generated migration file and update.
You can change the collation of any new objects that are created in a user database by using the COLLATE clause of the ALTER DATABASE statement. This statement does not change the collation of the columns in any existing user-defined tables. These can be changed by using the COLLATE clause of ALTER TABLE.
You need to create new migration and make column case sensitive using laravel schema builder with code mentioned below :
$table->string('columName')->collation('utf8_bin')->change();
https://laravel.com/docs/7.x/migrations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With