app/DoctrineMigrations/Version20251216160000.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.  * Thêm field email05 vào bảng dtb_base_info
  8.  */
  9. final class Version20251216160000 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Add email05 column to dtb_base_info table';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // Kiểm tra xem cột đã tồn tại chưa
  18.         if (!$schema->getTable('dtb_base_info')->hasColumn('email05')) {
  19.             $this->addSql("ALTER TABLE dtb_base_info ADD email05 VARCHAR(255) DEFAULT '' NOT NULL");
  20.         }
  21.     }
  22.     public function down(Schema $schema): void
  23.     {
  24.         // Xóa cột khi rollback
  25.         if ($schema->getTable('dtb_base_info')->hasColumn('email05')) {
  26.             $this->addSql('ALTER TABLE dtb_base_info DROP COLUMN email05');
  27.         }
  28.     }
  29. }