Files
thetool/db/migrations/20240510225400_add_ip_network.php
2024-05-10 23:07:21 +02:00

34 lines
1.5 KiB
PHP

<?php /** @noinspection ALL */
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddIpNetwork extends AbstractMigration {
public function up(): void {
if ($this->getEnvironment() == "thetool") {
// IpNetwork Table
$ipNetworkTable = $this->table("IpNetwork", ["signed" => true]);
$ipNetworkTable->addColumn("network_address", "integer", ["null" => false, "signed" => false])
->addColumn("cidr", "integer", ["null" => false])
->addColumn("parent_network_id", "integer", ["null" => true, "signed" => true])
->addColumn("status", "enum", ["values" => ["active", "inactive", "reserved"], "null" => false])
->addColumn("name", "string", ["null" => true, "limit" => 100])
->addColumn("description", "text", ["null" => true])
->addColumn("location", "string", ["null" => true, "limit" => 255])
->addColumn("create", "integer", ["null" => true, "signed" => false])
->addColumn("edit", "integer", ["null" => true, "signed" => false])
->addForeignKey("parent_network_id", "IpNetwork", "id", ["delete" => "SET_NULL", "update" => "NO_ACTION"])
->addIndex(["parent_network_id"]);
$ipNetworkTable->save();
}
}
public function down(): void {
if ($this->getEnvironment() == "thetool") {
$this->table("IpNetwork")->drop()->save();
}
}
}