Итерация 3: инвентарь устройств
- Миграция devices (name, type, ip, mac, hostname, vendor, os, location, importance, status) - Device model + DeviceRepository с полным CRUD - DeviceService для бизнес-логики - MergeSuggestionService для предложений объединения (MAC→90%, hostname→60%) - DeviceController: список, создание, редактирование, карточка, удаление, создание из discovered_host - Шаблоны: devices/index, devices/form, devices/show - Dashboard с реальными счётчиками (устройства, новые находки) - Кнопка «Создать устройство» в Discovery для новых хостов - DeviceRepository + DeviceService + DeviceController в DI
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateDevices extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table('devices');
|
||||
$table
|
||||
->addColumn('name', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('type', 'string', ['limit' => 30, 'null' => false, 'default' => 'unknown'])
|
||||
->addColumn('description', 'text', ['null' => true])
|
||||
->addColumn('primary_ip', 'string', ['limit' => 45, 'null' => true])
|
||||
->addColumn('mac_address', 'string', ['limit' => 17, 'null' => true])
|
||||
->addColumn('hostname', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('vendor', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('os_name', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('os_version', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('location', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('importance', 'string', ['limit' => 20, 'null' => false, 'default' => 'normal'])
|
||||
->addColumn('status', 'string', ['limit' => 20, 'null' => false, 'default' => 'active'])
|
||||
->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
||||
->addColumn('updated_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
||||
->addIndex(['primary_ip'])
|
||||
->addIndex(['mac_address'], ['unique' => true])
|
||||
->addIndex(['type'])
|
||||
->addIndex(['status'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user