migrations/Version20210114170336.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 Version20210114170336 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         $this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'system');");
  18.         $this->addSql("SET @id_login_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Login');");
  19.         $this->addSql("SET @id_register_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Registo');");
  20.         $this->addSql("UPDATE `std_config` SET `value`=@id_login_page WHERE `machine_name`='login_page';");
  21.         $this->addSql("UPDATE `std_config` SET `value`=@id_register_page WHERE `machine_name`='new_account_page';");
  22.         // Create page "Recuperar password"
  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`)
  24.          VALUES (NULL, 1, 1, @id_content_type, 1, NOW(), NOW(), NULL, NOW(), NULL, 'Recuperar password');");
  25.         $this->addSql("SET @id_recover_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Recuperar password');");
  26.         $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`)
  27.                 VALUES (@id_recover_page, 'pt', 1, 1, 1, NOW(), NOW(), 'Recuperar password', 'recuperar-password', '/pt/recuperar-password', '', '', '', '', '', '', '', '', '', '', '{\"fields\": {\"1\": {\"skin\": \"\", \"block\": \"reset_password\", \"isMaster\": 0, \"settings\": {\"expire_date\": \"\", \"publish_date\": \"\", \"disabled_block\": \"0\"}, \"blockname\": \"\", \"components\": {\"title\": \"Recuperar password\"}, \"repeatable\": [], \"templatesBlocksId\": 0}}}');");
  28.         //$this->addSql("INSERT INTO `std_pages_pages` (`page_id`, `relation_id`, `order_value`, `content_type`) VALUES (@id_recover_page, 0, 1, @id_content_type);");
  29.         $this->addSql("INSERT INTO `std_friendly_url` (`page_id`, `url`, `relation_tree`, `relation_id`, `language_code`, `is_canonical`) VALUES (@id_recover_page, '/pt/recuperar-password', '[]', NULL, 'pt', 1);");
  30.         $this->addSql("UPDATE `std_config` SET `value`=@id_recover_page WHERE `machine_name`='reset_password_page';");
  31.     }
  32.     
  33.     public function down(Schema $schema) : void
  34.     {        
  35.         $this->addSql("UPDATE `std_config` SET `value`='' WHERE `machine_name`='login_page';");
  36.         $this->addSql("UPDATE `std_config` SET `value`='' WHERE `machine_name`='new_account_page';");
  37.         $this->addSql("UPDATE `std_config` SET `value`='' WHERE `machine_name`='reset_password_page';");
  38.         $this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'system');");
  39.         
  40.         $this->addSql("DELETE FROM `std_friendly_url` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Recuperar password');");
  41.         $this->addSql("DELETE FROM `std_pages_pages` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Recuperar password');");
  42.         $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`='Recuperar password');");
  43.         $this->addSql("DELETE FROM `std_pages_content` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type AND `name`='Recuperar password');");
  44.         $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`='Recuperar password');");
  45.         $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`='Recuperar password');");
  46.         $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`='Recuperar password');");
  47.         $this->addSql("DELETE FROM `std_pages` WHERE `content_type`=@id_content_type AND `name`='Recuperar password';");
  48.     }
  49. }