migrations/Version20210212124045.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 Version20210212124045 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         $this->addSql("SET @menu_content_type = (SELECT id FROM std_content_types WHERE machine_name='menus');");
  18.         $this->addSql("SET @privatearea_content_type = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
  19.         $this->addSql("SET @menu_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Menu área reservada');");
  20.         $this->addSql("SET @menu_page_relation = (SELECT id FROM std_pages_pages WHERE `page_id`=@menu_page);");        
  21.         $this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_content_type AND name='Dados pessoais');");
  22.         $this->addSql("SET @child_page_canonical = (SELECT id FROM std_friendly_url WHERE `page_id`=@child_page AND is_canonical=1);");
  23.         $this->addSql("INSERT INTO `std_pages` (`template_id`, `created_by`, `updated_by`, `content_type`, `is_active`, `created_date`, `updated_date`, `order_value`, `publish_date`, `expire_date`, `name`) VALUES (NULL, 1, 1, @menu_content_type, 1, NOW(), NOW(), NULL, NULL, NULL, 'Dados pessoais');");
  24.         $this->addSql("SET @menu_child_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Dados pessoais');");
  25.         $this->addSql("INSERT INTO `std_pages_content` (`page_id`, `language_code`, `created_by`, `updated_by`, `is_active`, `created_date`, `updated_date`, `title`, `url`, `canonical_url`, `meta_title`, `meta_keywords`, `meta_description`, `og_title`, `og_image`, `og_description`, `og_url`, `scripts_head`, `scripts_body`, `scripts_footer`, `content`) VALUES (@menu_child_page, 'pt', 1, 1, 1, NOW(), NOW(), 'Dados pessoais', 'os-meus-dados', NULL, '', '', '', '', '', '', '', '', '', '', CONCAT('{\"id\": ',@child_page,', \"target\": \"_self\", \"relationId\": 0}'));");
  26.         $this->addSql("INSERT INTO `std_pages_pages` (`page_id`, `relation_id`, `order_value`, `content_type`) VALUES (@menu_child_page, @menu_page_relation, 1, @menu_content_type);");
  27.         $this->addSql("SET @menu_child_page_relation = (SELECT id FROM std_pages_pages WHERE `page_id`=@menu_child_page AND `relation_id` = @menu_page_relation AND `content_type` = @menu_content_type);");
  28.         $this->addSql("INSERT INTO `std_menus_friendly_url` (`menu_id`, `menu_relation_id`, `url_relation_id`, `friendly_url`, `language_code`, `page_id`) VALUES (@menu_page, @menu_page_relation, @menu_child_page_relation, @child_page_canonical, 'pt', @child_page);");
  29.     }
  30.     public function down(Schema $schema) : void
  31.     {
  32.         $this->addSql("SET @privatearea_content_type = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
  33.         $this->addSql("SET @menu_content_type = (SELECT id FROM std_content_types WHERE machine_name='menus');");
  34.         $this->addSql("SET @menu_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Menu área reservada');");
  35.         $this->addSql("SET @menu_page_relation = (SELECT id FROM std_pages_pages WHERE `page_id`=@menu_page);");
  36.         $this->addSql("SET @menu_child_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Dados pessoais');");
  37.         $this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_content_type AND name='Dados pessoais');");
  38.         $this->addSql("DELETE FROM `std_menus_friendly_url` WHERE `menu_id`=@menu_page AND `menu_relation_id`=@menu_page_relation AND `page_id`=@child_page;");
  39.         $this->addSql("DELETE FROM `std_pages_pages` WHERE `page_id`=@menu_child_page AND `relation_id`=@menu_page_relation;");
  40.         $this->addSql("DELETE FROM `std_pages_pages` WHERE `page_id`=@child_page AND `relation_id`=@menu_page_relation;");
  41.         $this->addSql("DELETE FROM `std_pages_content` WHERE `page_id`=@menu_child_page;");
  42.         $this->addSql("DELETE FROM `std_pages` WHERE `id`=@menu_child_page;");
  43.     }
  44. }