Files
thetool/db/migrations/20250605080000_preorder_notification_log_modify.php
2025-06-05 10:14:23 +02:00

59 lines
2.1 KiB
PHP

<?php
declare(strict_types = 1);
use Phinx\Migration\AbstractMigration;
final class PreorderNotificationLogModify extends AbstractMigration {
public function up(): void {
if ($this->getEnvironment() == "thetool") {
$PreorderStatusnotificationLogTable = $this->table("PreorderStatusnotificationLog");
if ($PreorderStatusnotificationLogTable->hasColumn("status_code")) {
$PreorderStatusnotificationLogTable
->changeColumn("status_code", "integer", ["null" => true])
->update();
}
if (!$PreorderStatusnotificationLogTable->hasColumn("email_type")) {
$PreorderStatusnotificationLogTable
->addColumn("email_type", "string", [
"limit" => 50,
"null" => true,
"after" => "email"
])
->update();
}
if (!$PreorderStatusnotificationLogTable->hasIndex(["email_type"])) {
$PreorderStatusnotificationLogTable
->addIndex(["email_type"], ["name" => "idx_email_type"])
->update();
}
}
}
public function down(): void {
if ($this->getEnvironment() == "thetool") {
$PreorderStatusnotificationLogTable = $this->table("PreorderStatusnotificationLog");
if ($PreorderStatusnotificationLogTable->hasIndex(["email_type"])) {
$PreorderStatusnotificationLogTable
->removeIndex(["email_type"])
->update();
}
if ($PreorderStatusnotificationLogTable->hasColumn("email_type")) {
$PreorderStatusnotificationLogTable
->removeColumn("email_type")
->update();
}
if ($PreorderStatusnotificationLogTable->hasColumn("status_code")) {
$PreorderStatusnotificationLogTable
->changeColumn("status_code", "integer", ["null" => false])
->update();
}
}
}
}