<?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 Version20210114170336 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
$this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'system');");
$this->addSql("SET @id_login_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Login');");
$this->addSql("SET @id_register_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Registo');");
$this->addSql("UPDATE `std_config` SET `value`=@id_login_page WHERE `machine_name`='login_page';");
$this->addSql("UPDATE `std_config` SET `value`=@id_register_page WHERE `machine_name`='new_account_page';");
// Create page "Recuperar password"
$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, @id_content_type, 1, NOW(), NOW(), NULL, NOW(), NULL, 'Recuperar password');");
$this->addSql("SET @id_recover_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Recuperar password');");
$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_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}}}');");
//$this->addSql("INSERT INTO `std_pages_pages` (`page_id`, `relation_id`, `order_value`, `content_type`) VALUES (@id_recover_page, 0, 1, @id_content_type);");
$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);");
$this->addSql("UPDATE `std_config` SET `value`=@id_recover_page WHERE `machine_name`='reset_password_page';");
}
public function down(Schema $schema) : void
{
$this->addSql("UPDATE `std_config` SET `value`='' WHERE `machine_name`='login_page';");
$this->addSql("UPDATE `std_config` SET `value`='' WHERE `machine_name`='new_account_page';");
$this->addSql("UPDATE `std_config` SET `value`='' WHERE `machine_name`='reset_password_page';");
$this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'system');");
$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');");
$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');");
$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');");
$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');");
$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');");
$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');");
$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');");
$this->addSql("DELETE FROM `std_pages` WHERE `content_type`=@id_content_type AND `name`='Recuperar password';");
}
}