41 lines
1.1 KiB
PHP
41 lines
1.1 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.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
|
|
Schema::create('objects', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('reference', 125)->nullable();
|
|
$table->string('name', 255);
|
|
$table->string('description', 255)->nullable();
|
|
$table->string('type', 125)->nullable();
|
|
$table->foreignId('contract_id')->constrained('contracts')->cascadeOnDelete();
|
|
// Indexes for faster lookups
|
|
$table->softDeletes();
|
|
$table->timestamps();
|
|
|
|
$table->index('type');
|
|
$table->index('reference');
|
|
$table->index('contract_id');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('objects');
|
|
Schema::dropIfExists('object_types');
|
|
}
|
|
};
|