File: /var/www/ipsremont-demo/database/migrations/2020_12_21_130722_create_device_parts_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateDevicePartsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('device_parts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('device_id');
$table->unsignedBigInteger('part_id');
$table->string('label')->comment('Подпись');
$table->integer('amount')->comment('Количество');
$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('part_id')->references('id')->on('parts')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('device_parts');
}
}