Added Voice tables & canVoiceplan permission
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user