id(); $table->uuid()->unique(); $table->foreignId('device_id')->constrained()->cascadeOnDelete(); $table->foreignId('entity_id')->nullable()->constrained()->nullOnDelete(); $table->string('source'); // user | automation | physical $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete(); $table->string('command'); // turn_on | turn_off | reboot | … $table->json('payload')->nullable(); $table->string('result')->nullable(); // ok | error: … $table->timestamps(); $table->index(['device_id', 'created_at']); }); } public function down(): void { Schema::dropIfExists('commands'); } };