Files
thetool/db/migrations/20240220145156_address_add_country_id.php
2024-02-20 20:20:48 +01:00

57 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddressAddCountryId extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$table = $this->table("Address");
$table->addColumn("country_id", "integer", ["null" => true, "default" => null, "after" => "country"]);
$table->save();
// call country_id update script
$orig_dir = getcwd();
chdir(BASEDIR."/scripts");
echo " * running \033[1;32mscripts/address-update-country_id.php\033[0m to populate Address.country_id\n";
$return = shell_exec("/usr/bin/env php ".BASEDIR."/scripts/address-update-country_id.php");
chdir($orig_dir);
if($return) {
die("Error while running county_id update script:\n\n\033[1;31m$return\033[0m\n\nAborting.");
}
echo "\033[1;31m=====================================\033[0m\n";
echo "\033[1;31m===\033[0m address-update-country_id.php \033[1;31m===\033[0m\n";
echo "\033[1;31m===\033[0m ist gelaufen. \033[1;31m===\033[0m\n";
echo "\033[1;31m===\033[0m ----------------------------- \033[1;31m===\033[0m\n";
echo "\033[1;31m===\033[0m \033[1;32mWenn keine Fehler:\033[0m \033[1;31m===\033[0m\n";
echo "\033[1;31m===\033[0m \033[1;31m===\033[0m\n";
echo "\033[1;31m===\033[0m \033[1;32mBitte Spalte 'country' aus\033[0m \033[1;31m===\033[0m\n";
echo "\033[1;31m===\033[0m \033[1;32mtable 'Address' löschen!!!\033[0m \033[1;31m===\033[0m\n";
echo "\033[1;31m=====================================\033[0m\n";
// remove country
//$this->table("Address")->removeColumn("country")->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("Address")->removeColumn("country_id")->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
}