Files
thetool/db/migrations/20260220100000_pop_add_address_fields.php
2026-02-20 11:22:21 +01:00

37 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class PopAddAddressFields extends AbstractMigration
{
public function up(): void
{
$table = $this->table('Pop');
if (!$table->hasColumn('zip')) {
$table->addColumn('zip', 'string', ['null' => true, 'limit' => 10, 'after' => 'location']);
}
if (!$table->hasColumn('city')) {
$table->addColumn('city', 'string', ['null' => true, 'limit' => 255, 'after' => 'zip']);
}
if (!$table->hasColumn('street')) {
$table->addColumn('street', 'string', ['null' => true, 'limit' => 255, 'after' => 'city']);
}
if (!$table->hasColumn('number')) {
$table->addColumn('number', 'string', ['null' => true, 'limit' => 20, 'after' => 'street']);
}
$table->update();
}
public function down(): void
{
$table = $this->table('Pop');
$table->removeColumn('zip')
->removeColumn('city')
->removeColumn('street')
->removeColumn('number')
->update();
}
}