<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251124000000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Insert new domain value "curtas" under "programas" tag if it does not exist';
}
public function up(Schema $schema): void
{
// Check if 'curtas' already exists before inserting
$this->addSql("
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`)
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'
FROM DUAL
WHERE NOT EXISTS (
SELECT 1 FROM std_domains_values WHERE machine_name = 'curtas'
);
");
}
public function down(Schema $schema): void
{
// Remove the inserted row
$this->addSql("DELETE FROM std_domains_values WHERE machine_name = 'curtas';");
}
}