I’m currently working on a Laravel application and need to set a custom default string length for a database connection other than the default one. Specifically, I’m using a database connection named latest-iad-db and encountering the following error when running the migration:
I’ve already set the default string length for the default connection in the AppServiceProvider like so:
Schema::defaultStringLength(191);
Also i’m getting this error:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (Connection: latest-iad-db, SQL: alter table `lounges` add unique `places__id_airport_id_category_id_unique`(`_id`, `airport_id`, `category_id`))
However, this doesn’t seem to work for my custom database connection (latest-iad-db), which is causing the above error.
I want to know how I can set the default string length specifically for the latest-iad-db connection to avoid this error.
I tried the following, but it didn’t work:
Schema::connection('latest-iad-db')->defaultStringLength(191);
Can anyone suggest how I can resolve this or provide an example of setting the default string length for a specific connection in Laravel?