45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class AddCanVoicePlanPermission extends AbstractMigration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if($this->getEnvironment() == "thetool") {
|
|
$table = $this->table("WorkerPermission");
|
|
$table->addColumn("canVoiceplan", "enum", ["values" => 'false,true', "default" => "false", "after" => "canVoipnumbering"]);
|
|
$table->update();
|
|
|
|
// set canVoiceplan true where canVoipnumbering is true
|
|
$builder = $this->getQueryBuilder();
|
|
$q = $builder->select("*")->from("WorkerPermission")->where(["canVoipnumbering" => "true"])->execute();
|
|
|
|
while($perm = $q->fetch('assoc')) {
|
|
$id = $perm["id"];
|
|
|
|
$this->query("UPDATE WorkerPermission SET canVoiceplan='true' WHERE id=$id");
|
|
|
|
}
|
|
}
|
|
|
|
if($this->getEnvironment() == "addressdb") {
|
|
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
if($this->getEnvironment() == "thetool") {
|
|
$table = $this->table("WorkerPermission");
|
|
$table->removeColumn("canVoiceplan");
|
|
$table->update();
|
|
}
|
|
|
|
if($this->getEnvironment() == "addressdb") {
|
|
|
|
}
|
|
}
|
|
}
|