40 lines
906 B
PHP
40 lines
906 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use App\Enums\DocumentType;
|
|
|
|
class CreateDocumentsTable extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::create('documents', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name');
|
|
$table->enum('document_type', DocumentType::getValues())
|
|
->default(DocumentType::Other);
|
|
$table->foreignId('car_id')
|
|
->onUpdate('cascade')
|
|
->onDelete('cascade')
|
|
->constrained('cars');
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('documents');
|
|
}
|
|
}
|