Teren-app/database/migrations/2025_09_27_210113_alter_table_objects.php
Simon Pocrnjič a913cfc381 Changes
2025-09-28 00:30:18 +02:00

43 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::dropIfExists('objects');
Schema::dropIfExists('object_types');
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');
}
};