Files
thetool/db/migrations/20240410150500_add_voice_call_history.php
2024-04-10 13:32:15 +00:00

46 lines
2.3 KiB
PHP

<?php /** @noinspection ALL */
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddVoiceCallHistory extends AbstractMigration {
public function up(): void {
if ($this->getEnvironment() == "thetool") {
//VoiceCallHistory Table
$voiceCallHistoryTable = $this->table("VoiceCallHistory", ["signed" => true]);
$voiceCallHistoryTable->addColumn("uid", "string", ["null" => false, "limit" => 255]);
$voiceCallHistoryTable->addColumn("voice_account", "string", ["null" => true, "limit" => 255]);
$voiceCallHistoryTable->addColumn("start", "datetime", ["null" => false]);
$voiceCallHistoryTable->addColumn("source", "string", ["null" => true, "limit" => 255]);
$voiceCallHistoryTable->addColumn("destination", "string", ["null" => true, "limit" => 255]);
$voiceCallHistoryTable->addColumn("state", "integer", ["null" => true]);
$voiceCallHistoryTable->addColumn("billable", "integer", ["null" => false, "limit" => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]);
$voiceCallHistoryTable->addColumn("duration", "integer", ["null" => false]);
//VoiceCallHistory Table Indexes
$voiceCallHistoryTable->addIndex(["billable"]);
$voiceCallHistoryTable->addIndex(["voice_account"]);
$voiceCallHistoryTable->addIndex(["uid"], ["unique" => true]);
$voiceCallHistoryTable->save();
//VoiceCallHistoryJob Table
$voiceCallHistoryJobTable = $this->table("VoiceCallHistoryJob", ["signed" => true]);
$voiceCallHistoryJobTable->addColumn("date", "date", ["null" => false]);
$voiceCallHistoryJobTable->addColumn("status", "enum", ["values" => ["created", "pending", "running", "success", "failed"], "default" => "created", "null" => false]);
$voiceCallHistoryJobTable->addColumn("finished", "date", ["null" => true]);
$voiceCallHistoryJobTable->addIndex(["date"], ["unique" => true]);
$voiceCallHistoryJobTable->save();
}
}
public function down(): void {
if ($this->getEnvironment() == "thetool") {
$this->table("VoiceCallHistory")->drop()->save();
$this->table("VoiceCallHistoryJob")->drop()->save();
}
}
}