How can indexes be checked if they exist in a Laravel migration?
问题 Trying to check if a unique index exists on a table when preparing a migration, how can it be achieved? Schema::table('persons', function (Blueprint $table) { if ($table->hasIndex('persons_body_unique')) { $table->dropUnique('persons_body_unique'); } }) Something that looks like the above. (apparently, hasIndex() doesn't exist) 回答1: Using "doctrine-dbal" that Laravel uses is better solution: Schema::table('persons', function (Blueprint $table) { $sm = Schema::getConnection()-