improved ipam

This commit is contained in:
2025-08-26 17:25:04 +02:00
parent 177a02c8c8
commit 4e2bb1c589

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
use Phinx\Migration\AbstractMigration; use Phinx\Migration\AbstractMigration;
@@ -7,54 +8,73 @@ final class RmlworkorderMultiTenant extends AbstractMigration
{ {
public function up(): void public function up(): void
{ {
if ($this->getEnvironment() == "thetool") { if ($this->getEnvironment() !== "thetool") {
$companyTable = $this->table('RMLWorkorderCompany'); return;
if (!$companyTable->hasColumn('visibleForAddressId')) {
$companyTable->addColumn('visibleForAddressId', 'text', ['null' => true, 'default' => null, 'after' => 'name'])
->save();
}
if (!$this->hasTable('RMLWorkorderTenantConfig')) {
$tenantConfigTable = $this->table('RMLWorkorderTenantConfig', ['id' => false, 'primary_key' => ['id']]);
$tenantConfigTable->addColumn('id', 'integer', ['identity' => true, 'signed' => false])
->addColumn('addressId', 'integer')
->addColumn('name', 'string', ['limit' => 255])
->addColumn('documentationTypes', 'json')
->addColumn('workorderCreationFilters', 'json')
->addColumn('create', 'integer')
->addColumn('createBy', 'integer')
->addIndex(['addressId'], ['name' => 'addressId_idx'])
->create();
}
$this->table('RMLWorkorderTenantConfig')->insert([
[
'id' => 1,
'addressId' => 4807,
'name' => 'RML Standard',
'documentationTypes' => '[{\"value\": \"photo_hup_mounted\", \"text\": \"Foto vom montierten HÜP\"}, {\"value\": \"photo_hup_open\", \"text\": \"Foto von dem offenen HÜP\"}, {\"value\": \"photo_splice_cassette_hup\", \"text\": \"Foto der Spleißkassette HÜP\"}, {\"value\": \"photo_splice_cassette_fcp\", \"text\": \"Foto der Spleißkassette - FCP\"}, {\"value\": \"photo_hup_closed_stickers\", \"text\": \"Foto vom geschlossenen HÜP mit allen Aufklebern\"}, {\"value\": \"photo_fcp_labeled\", \"text\": \"Foto vom FCP beschriftet\"}, {\"value\": \"photo_patch_position_osp\", \"text\": \"Foto der Patch-Position - OSP-Seite\"}, {\"value\": \"photo_patch_position_anb\", \"text\": \"Foto der Patch-Position - ANB-Seite\"}, {\"value\": \"measurement_protocol_otdr\", \"text\": \"ODTR Messung (1310nm & 1550nm)\"}]',
'workorderCreationFilters' => '{\"status_code\": 220, \"preorder_status_flags_all\": [3, 5]}',
'create' => 1724704509,
'createBy' => 1
]
])->save();
$this->execute("UPDATE RMLWorkorderCompany SET visibleForAddressId = '[4807]' WHERE visibleForAddressId IS NULL;");
} }
$companyTable = $this->table('RMLWorkorderCompany');
if (!$companyTable->hasColumn('visibleForAddressId')) {
$companyTable->addColumn('visibleForAddressId', 'text', ['null' => true, 'default' => null, 'after' => 'name'])->save();
}
if (!$this->hasTable('RMLWorkorderTenantConfig')) {
$this->table('RMLWorkorderTenantConfig', ['id' => false, 'primary_key' => ['id']])
->addColumn('id', 'integer', ['identity' => true, 'signed' => false])
->addColumn('addressId', 'integer')
->addColumn('name', 'string', ['limit' => 255])
->addColumn('documentationTypes', 'json')
->addColumn('workorderCreationFilters', 'json')
->addColumn('create', 'integer')
->addColumn('createBy', 'integer')
->addIndex(['addressId'], ['name' => 'addressId_idx'])
->create();
}
$docTypes = [
['value' => 'photo_hup_mounted', 'text' => 'Foto vom montierten HÜP'],
['value' => 'photo_hup_open', 'text' => 'Foto von dem offenen HÜP'],
['value' => 'photo_splice_cassette_hup', 'text' => 'Foto der Spleißkassette HÜP'],
['value' => 'photo_splice_cassette_fcp', 'text' => 'Foto der Spleißkassette - FCP'],
['value' => 'photo_hup_closed_stickers', 'text' => 'Foto vom geschlossenen HÜP mit allen Aufklebern'],
['value' => 'photo_fcp_labeled', 'text' => 'Foto vom FCP beschriftet'],
['value' => 'photo_patch_position_osp', 'text' => 'Foto der Patch-Position - OSP-Seite'],
['value' => 'photo_patch_position_anb', 'text' => 'Foto der Patch-Position - ANB-Seite'],
['value' => 'measurement_protocol_otdr', 'text' => 'ODTR Messung (1310nm & 1550nm)'],
];
$workorderFilters = [
'status_code' => 220,
'preorder_status_flags_all' => [3, 5],
];
$this->table('RMLWorkorderTenantConfig')->insert([
[
'id' => 1,
'addressId' => 4807,
'name' => 'RML Standard',
'documentationTypes' => json_encode($docTypes),
'workorderCreationFilters' => json_encode($workorderFilters),
'create' => 1724704509,
'createBy' => 1
]
])->save();
$this->execute("UPDATE RMLWorkorderCompany SET visibleForAddressId = '[4807]' WHERE visibleForAddressId IS NULL;");
} }
public function down(): void public function down(): void
{ {
if ($this->getEnvironment() == "thetool") { if ($this->getEnvironment() !== "thetool") {
if ($this->hasTable('RMLWorkorderTenantConfig')) { return;
$this->table('RMLWorkorderTenantConfig')->drop()->save(); }
}
$companyTable = $this->table('RMLWorkorderCompany'); if ($this->hasTable('RMLWorkorderTenantConfig')) {
if ($companyTable->hasColumn('visibleForAddressId')) { $this->table('RMLWorkorderTenantConfig')->drop()->save();
$companyTable->removeColumn('visibleForAddressId') }
->save();
} $companyTable = $this->table('RMLWorkorderCompany');
if ($companyTable->hasColumn('visibleForAddressId')) {
$companyTable->removeColumn('visibleForAddressId')->save();
} }
} }
} }