41 lines
872 B
PHP
41 lines
872 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class UniqueColumns extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
dump(DB::select(DB::raw("DELETE t1 FROM nde_matrices t1
|
|
INNER JOIN nde_matrices t2
|
|
WHERE
|
|
t1.id < t2.id AND
|
|
t1.line = t2.line AND
|
|
t1.type_of_joint = t2.type_of_joint AND
|
|
t1.fluid = t2.fluid
|
|
;")));
|
|
|
|
Schema::table("nde_matrices", function (Blueprint $table) {
|
|
$table->unique(['line', 'type_of_joint', 'fluid']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
//
|
|
}
|
|
}
|