25 lines
830 B
PHP
25 lines
830 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('devices', function (Blueprint $t) {
|
||
|
|
$t->id();
|
||
|
|
$t->foreignId('tenant_id')->constrained('tenants')->cascadeOnDelete();
|
||
|
|
$t->string('name',100);
|
||
|
|
$t->string('slug',50);
|
||
|
|
$t->string('type',30)->default('ems-esp');
|
||
|
|
$t->string('mqtt_topic_prefix',100);
|
||
|
|
$t->string('mqtt_username',50)->nullable();
|
||
|
|
$t->string('timezone',50)->default('Europe/Berlin');
|
||
|
|
$t->json('settings')->nullable();
|
||
|
|
$t->timestamp('last_seen_at')->nullable();
|
||
|
|
$t->timestamps();
|
||
|
|
$t->unique(['tenant_id','slug']);
|
||
|
|
$t->index('tenant_id');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
public function down(): void { Schema::dropIfExists('devices'); }
|
||
|
|
};
|