migrations/Version20230427140453.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20230427140453 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Placeholder country, id 1000 code zz';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // Add placeholder country with ID 1000 and code "ZZ" to the countries table
  18.         $this->addSql("INSERT INTO country (id, name, iso_code, sms_enabled) VALUES (1000, 'Not Available', 'zz', 1)");
  19.         // Set default value for the country field in the users table
  20.         $this->addSql("ALTER TABLE creator ALTER country_id SET DEFAULT 1000");
  21.         // To update existing users without a country, run the command:
  22.         // php bin/console app:update-default-country
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // Set default value for the country field in the users table
  27.         $this->addSql("ALTER TABLE creator ALTER country_id SET DEFAULT NULL");
  28.         // Full rollback is more complex and if a complete rollback on production is required, a separate command needs to be written
  29.     }
  30. }