migrations/Version20230412154318.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 Version20230412154318 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         // Create page "Termos & condições"
  19.         $this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'private_area');");
  20.         $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`)
  21.          VALUES (NULL, 1, 1, @id_content_type, 1, NOW(), NOW(), NULL, NOW(), NULL, 'Notificações');");
  22.         $this->addSql("SET @id_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Notificações');");
  23.         $arrayJsonContent = ["fields"=> [
  24.                 "1"=> [
  25.                     "skin"=> ""
  26.                     "block"=> "web_users_notifications"
  27.                     "isMaster"=> 0
  28.                     "settings"=> [
  29.                         "margin"=> "" "offset"=> "0" "padding"=> "" "expire_date"=> "" "extra_class"=> "" "publish_date"=> "" "disabled_block"=> "0" "extra_block_id"=> """item_label"=> ""]
  30.                     , "blockname"=> ""
  31.                     "components"=> [
  32.                         "title"=> "Notificações"]
  33.                     , "repeatable"=> []
  34.                     , "templatesBlocksId"=> 0
  35.                 ]
  36.             ]
  37.         ];
  38.         $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 (@id_page, 'pt', 1, 1, 1, now(), now(), 'Notificações', 'notificacoes', '/pt/notificacoes', '', '', '', '', '', '', '', '', '', '', '".json_encode($arrayJsonContentJSON_UNESCAPED_UNICODE)."');");
  39.         $this->addSql("INSERT INTO `std_friendly_url` (`page_id`, `url`, `relation_tree`, `relation_id`, `language_code`, `is_canonical`) VALUES (@id_page, '/pt/notificacoes', '[]', NULL, 'pt', 1);");    
  40.         // add role to page
  41.         $this->addSql("SET @web_role = (SELECT id FROM `std_web_roles` WHERE `name` = 'ROLE_USER');");
  42.         $this->addSql("INSERT INTO `std_page_web_role` (`page_id`, `webrole_id`) VALUES (@id_page, @web_role);");
  43.         // config
  44.         $this->addSql("
  45.             INSERT INTO `std_config` (`machine_name`, `created_by`, `updated_by`, `value`, `description_machine_name`, `details_machine_name`, `parent_name`, `variable_type`, `order_value`, `is_hidden`, `is_active`, `created_date`, `updated_date`, `label`, `content`, `language_code`) 
  46.             VALUES 
  47.             ('notifications_pages', 1, 1, '', 'notifications_pages', 'notifications_pages', 'Private area', 'SELECT', 2, 0, 1, now(), now(), 'Página Notificações', '{\"query\": \"select p.`name` as label,p.id as id from std_pages p INNER JOIN std_content_types sct ON p.content_type = sct.id  where sct.machine_name LIKE \'private_area\'\"}', '');
  48.         ");
  49.         $this->addSql("SET @menu_content_type = (SELECT id FROM std_content_types WHERE machine_name='menus');");
  50.         $this->addSql("SET @privatearea_content_type = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
  51.         $this->addSql("SET @menu_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Menu área reservada');");
  52.         $this->addSql("SET @menu_page_relation = (SELECT id FROM std_pages_pages WHERE `page_id`=@menu_page);");        
  53.         $this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_content_type AND name='Notificações');");
  54.         $this->addSql("SET @child_page_canonical = (SELECT id FROM std_friendly_url WHERE `page_id`=@child_page AND is_canonical=1);");
  55.         $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, 'Notificações');");
  56.         $this->addSql("SET @menu_child_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Notificações');");
  57.         $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(), 'Notificações', 'notificacoes', NULL, '', '', '', '', '', '', '', '', '', '', CONCAT('{\"id\": ',@child_page,', \"target\": \"_self\", \"relationId\": 0}'));");
  58.         $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);");
  59.         $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);");
  60.         $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);");
  61.     }
  62.     public function down(Schema $schema): void
  63.     {
  64.         // this down() migration is auto-generated, please modify it to your needs
  65.         $this->addSql("SET @privatearea_content_type = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
  66.         $this->addSql("SET @menu_content_type = (SELECT id FROM std_content_types WHERE machine_name='menus');");
  67.         $this->addSql("SET @menu_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Menu área reservada');");
  68.         $this->addSql("SET @menu_page_relation = (SELECT id FROM std_pages_pages WHERE `page_id`=@menu_page);");
  69.         $this->addSql("SET @menu_child_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Notificações');");
  70.         $this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_content_type AND name='Notificações');");
  71.         $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;");
  72.         $this->addSql("DELETE FROM `std_pages_pages` WHERE `page_id`=@menu_child_page AND `relation_id`=@menu_page_relation;");
  73.         $this->addSql("DELETE FROM `std_pages_pages` WHERE `page_id`=@child_page AND `relation_id`=@menu_page_relation;");
  74.         $this->addSql("DELETE FROM `std_pages_content` WHERE `page_id`=@menu_child_page;");
  75.         $this->addSql("DELETE FROM `std_pages` WHERE `id`=@menu_child_page;");
  76.         $this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'private_area');");
  77.         $this->addSql("DELETE FROM `std_friendly_url` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Notificações');");
  78.         $this->addSql("DELETE FROM `std_pages_pages` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Notificações');");
  79.         $this->addSql("DELETE FROM `std_page_web_role` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Notificações');");
  80.         $this->addSql("DELETE FROM `std_pages_content` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Notificações');");
  81.         $this->addSql("DELETE FROM `std_favorite_pages_users` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Notificações');");
  82.         $this->addSql("DELETE FROM `std_menus_friendly_url` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Notificações');");
  83.         $this->addSql("DELETE FROM `std_page_web_role` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Notificações');");
  84.         $this->addSql("DELETE FROM `std_pages` WHERE `content_type`=@id_content_type AND `name`='Notificações';");
  85.         $this->addSql("DELETE FROM `std_config` where machine_name= 'notifications_pages';");
  86.     }
  87. }