migrations/Version20251124000000.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 Version20251124000000 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Insert new domain value "curtas" under "programas" tag if it does not exist';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // Check if 'curtas' already exists before inserting
  18.         $this->addSql("
  19.             INSERT INTO `std_domains_values` (`updated_by`, `language_code`, `created_by`, `domain_id`, `machine_name`, `description`, `parent_domain_value_id`, `is_active`, `created_date`, `updated_date`, `domain_type`)
  20.             SELECT 1, 'pt', 1, (SELECT id FROM std_domains WHERE machine_name = 'tags' LIMIT 1), 'curtas', 'Curtas', (SELECT id FROM std_domains_values WHERE machine_name = 'programas' LIMIT 1), 1, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP(), 'Tipo de Programa'
  21.             FROM DUAL
  22.             WHERE NOT EXISTS (
  23.                 SELECT 1 FROM std_domains_values WHERE machine_name = 'curtas'
  24.             );
  25.         ");
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // Remove the inserted row
  30.         $this->addSql("DELETE FROM std_domains_values WHERE machine_name = 'curtas';");
  31.     }
  32. }