File: /var/www/ipsremont-demo/database/migrations/2020_12_16_140434_create_devices_schema_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateDevicesSchemaTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('devices_schema', function (Blueprint $table) {
$table->unsignedBigInteger('device_id');
$table->unsignedBigInteger('schema_id');
$table->softDeletes();
$table->timestamp('created_at')->nullable()->useCurrent();
$table->timestamp('updated_at')->nullable()->useCurrent();
$table->foreign('device_id')->references('id')->on('devices')->onDelete('cascade');
$table->foreign('schema_id')->references('id')->on('schema')->onDelete('cascade');
$table->primary(['device_id','schema_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('devices_schema');
}
}