homeos/database/migrations/2026_07_17_201003_create_en...

30 lines
940 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('entities', function (Blueprint $table) {
$table->id();
$table->uuid()->unique();
$table->foreignId('device_id')->constrained()->cascadeOnDelete();
$table->string('type'); // switch | light | power | contact | temperature | humidity | motion | battery
$table->string('key'); // e.g. switch:0, cover:0
$table->string('name')->nullable();
$table->json('capabilities')->nullable();
$table->timestamps();
$table->unique(['device_id', 'key']);
});
}
public function down(): void
{
Schema::dropIfExists('entities');
}
};