Files
thetool/db/migrations/20250912080000_add_rimo_fcp_index.php
2025-09-12 09:18:15 +02:00

54 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddRimoFcpIndex extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "addressdb") {
$table = $this->table('Hausnummer');
if (!$table->hasIndexByName('idx_fcp_id_rimo_type')) {
$table->addIndex(['fcp_id', 'rimo_type'], ['name' => 'idx_fcp_id_rimo_type'])
->update();
}
}
if ($this->getEnvironment() == "thetool") {
$table = $this->table('Preorder');
if (!$table->hasIndexByName('idx_adb_hausnummer_id')) {
$table->addIndex(['adb_hausnummer_id'], ['name' => 'idx_adb_hausnummer_id']);
}
if (!$table->hasIndexByName('idx_status_id')) {
$table->addIndex(['status_id'], ['name' => 'idx_status_id']);
}
$table->update();
}
}
public function down(): void
{
if ($this->getEnvironment() == "addressdb") {
$table = $this->table('Hausnummer');
if ($table->hasIndexByName('idx_fcp_id_rimo_type')) {
$table->removeIndexByName('idx_fcp_id_rimo_type')
->update();
}
}
if ($this->getEnvironment() == "thetool") {
$table = $this->table('Preorder');
if ($table->hasIndexByName('idx_adb_hausnummer_id')) {
$table->removeIndexByName('idx_adb_hausnummer_id');
}
if ($table->hasIndexByName('idx_status_id')) {
$table->removeIndexByName('idx_status_id');
}
$table->update();
}
}
}