@@ -13,14 +13,13 @@ public function up(): void
1313 {
1414 if (Schema::hasTable ('social_family_connections ' )) {
1515 Schema::table ('social_family_connections ' , function (Blueprint $ table ) {
16- // if an old default-named index made it into the database we need to
17- // remove it before adding a properly named, shorter index.
18- // Using dropIndex with the column list will generate the same long
19- // identifier Laravel would have used originally, so it will be
20- // dropped if present and ignored otherwise.
21- $ table ->dropIndex (['connected_account_id ' , 'matched_social_id ' ]);
16+ // drop the short index if it exists; this avoids ever mentioning the
17+ // long, auto-generated name which MySQL refuses to parse.
18+ // We use the explicit name so Laravel doesn't build the default one.
19+ $ table ->dropIndex ('sfc_account_social_id_idx ' );
2220
23- // add the newer short name; if it's already there this is a no-op
21+ // now ensure the properly named, shorter index is present. If it
22+ // already exists the builder will ignore the second creation.
2423 $ table ->index (
2524 ['connected_account_id ' , 'matched_social_id ' ],
2625 'sfc_account_social_id_idx '
@@ -36,10 +35,10 @@ public function down(): void
3635 {
3736 if (Schema::hasTable ('social_family_connections ' )) {
3837 Schema::table ('social_family_connections ' , function (Blueprint $ table ) {
38+ // simply remove the fixed index; the original long-named index
39+ // cannot be created on MySQL, so we don't attempt to recreate it
40+ // during rollback. This keeps the rollback safe and idempotent.
3941 $ table ->dropIndex ('sfc_account_social_id_idx ' );
40- // restore the original index name (long) so the rollback restores
41- // the previous state exactly; Laravel will recompute it for us.
42- $ table ->index (['connected_account_id ' , 'matched_social_id ' ]);
4342 });
4443 }
4544 }
0 commit comments