Fix vendor_ouis duplicates in migration (#15202)

* Fix vendor_ouis duplicates in migration
Can't trim the duplicates efficiently due to lacking an index on oui.

* fix style

* restrict columns to make strict group by happy.
This commit is contained in:
Tony Murray 2023-08-04 20:57:48 -05:00 committed by GitHub
parent 6fb784a321
commit 3170ec1399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,11 @@ return new class extends Migration
*/
public function up(): void
{
// if duplicate entries, truncate the table. Hard to delete due to lacking index.
if (DB::table('vendor_ouis')->select('oui')->havingRaw('count(oui) > 1')->groupBy('oui')->exists()) {
DB::table('vendor_ouis')->truncate();
}
Schema::table('vendor_ouis', function (Blueprint $table) {
$table->string('oui', 12)->change();
$table->unique(['oui']);