2026-05-07 23:31:33 +02:00
|
|
|
<?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('inspections', function (Blueprint $table) {
|
|
|
|
|
$table->id();
|
2026-06-19 18:40:54 +02:00
|
|
|
$table->uuid('uuid')->nullable()->unique();
|
2026-05-07 23:31:33 +02:00
|
|
|
$table->foreignId('project_id')->constrained()->onDelete('cascade');
|
|
|
|
|
$table->foreignId('layer_id')->constrained()->onDelete('cascade');
|
|
|
|
|
$table->string('feature_id'); // ID del elemento GeoJSON
|
|
|
|
|
$table->foreignId('template_id')->nullable()->constrained('inspection_templates')->onDelete('set null');
|
|
|
|
|
$table->foreignId('user_id')->constrained();
|
|
|
|
|
$table->json('data'); // Valores de los campos del template
|
2026-06-19 18:40:54 +02:00
|
|
|
$table->enum('status', ['pending', 'in_progress', 'completed', 'approved', 'rejected'])->default('pending');
|
|
|
|
|
$table->foreignId('inspector_user_id')->nullable()->constrained('users')->nullOnDelete();
|
|
|
|
|
$table->timestamp('completed_at')->nullable();
|
|
|
|
|
$table->enum('result', ['pass', 'fail', 'conditional'])->nullable();
|
|
|
|
|
$table->text('notes')->nullable();
|
|
|
|
|
$table->timestamp('client_updated_at')->nullable();
|
2026-05-07 23:31:33 +02:00
|
|
|
$table->timestamps();
|
2026-06-19 18:40:54 +02:00
|
|
|
$table->softDeletes();
|
2026-05-07 23:31:33 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reverse the migrations.
|
|
|
|
|
*/
|
|
|
|
|
public function down(): void
|
|
|
|
|
{
|
|
|
|
|
Schema::dropIfExists('inspections');
|
|
|
|
|
}
|
|
|
|
|
};
|