33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
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('devices', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->uuid()->unique();
|
|
$table->string('name');
|
|
$table->string('vendor')->nullable();
|
|
$table->string('model')->nullable();
|
|
$table->string('protocol')->nullable(); // mqtt | http | ble | …
|
|
$table->json('config')->nullable(); // topic prefix / ip / auth ref
|
|
$table->foreignId('room_id')->nullable()->constrained()->nullOnDelete();
|
|
$table->string('status')->default('active'); // discovered | active | ignored
|
|
$table->timestamp('last_seen_at')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->index('status');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('devices');
|
|
}
|
|
};
|