56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::create('makes', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->timestamps();
|
|
$table->string('name')->unique();
|
|
});
|
|
|
|
Schema::create('models', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->timestamps();
|
|
$table->string('name')->nullable();
|
|
|
|
$table->bigInteger('make_id')->unsigned()->nullable();
|
|
$table->foreign('make_id')->references('id')->on('makes');
|
|
|
|
$table->unique(['name','make_id']);
|
|
});
|
|
|
|
Schema::create('software', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->timestamps();
|
|
$table->string('name')->nullable();
|
|
|
|
$table->bigInteger('model_id')->unsigned()->nullable();
|
|
$table->foreign('model_id')->references('id')->on('models');
|
|
|
|
$table->unique(['name','model_id']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('software');
|
|
Schema::dropIfExists('models');
|
|
Schema::dropIfExists('makes');
|
|
}
|
|
}; |