<?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 Version20210225111032 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
// Create block "Web User Addresses"
$this->addSql("INSERT INTO `std_blocks` (`created_by`, `updated_by`, `machine_name`, `created_date`, `updated_date`, `name`, `settings`) VALUES ('1', '1', 'web_users_addresses', NOW(), NOW(), 'Moradas do utilizador', '{\"isWebUsersAddresses\": true}');");
$this->addSql("SET @id_block = LAST_INSERT_ID();");
$this->addSql("INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES ('title', @id_block, 1, 1, 'INPUT', NULL, 10, 1, NOW(), NOW(), 'Título', 0);");
$this->addSql("INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `order_value`, `created_date`, `updated_date`, `name`) VALUES ('addnew', @id_block, '1', '1', 'CHECKBOX', '1', '2021-01-07 15:46:30', '2021-01-07 15:46:31', 'Permite criar novas moradas?');");
$this->addSql("INSERT INTO `std_blocks_settings` (`machine_name`, `block_id`, `created_by`, `updated_by`, `name`, `setting_type`, `is_active`, `created_date`, `updated_date`, `order_value`, `settings`) VALUES ('disabled_block', @id_block, 1, 1, 'Disabled block', 'CHECKBOX', 1, '2020-06-22 15:27:32', '2020-06-22 15:27:32', -1, NULL);");
$this->addSql("SET @privatearea_contenttype = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'private_area');");
$this->addSql("SET @default_webrole = (SELECT id FROM `std_web_roles` WHERE `is_default` = 1 LIMIT 1);");
$this->addSql("SET @id_home_page = (SELECT id FROM `std_pages` WHERE `content_type` = @privatearea_contenttype AND `name`='Área reservada');");
$this->addSql("SET @id_home_page_relation = (SELECT id FROM `std_pages_pages` WHERE `page_id` = @id_home_page);");
// Create page "Addresses"
$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, @privatearea_contenttype, 1, NOW(), NOW(), NULL, NOW(), NULL, 'Moradas');");
$this->addSql("SET @childpage = (SELECT id FROM `std_pages` WHERE `content_type` = @privatearea_contenttype AND `name`='Moradas');");
$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 (@childpage, 'pt', 1, 1, 1, NOW(), NOW(), 'Moradas', 'moradas', '/pt/area-reservada/moradas', '', '', '', '', '', '', '', '', '', '', '{\"fields\": {\"1\": {\"skin\": \"\", \"block\": \"web_users_addresses\", \"isMaster\": 0, \"settings\": {\"expire_date\": \"\", \"publish_date\": \"\"}, \"blockname\": \"\", \"components\": {\"title\": \"Moradas\",\"addnew\":1}, \"repeatable\": [], \"templatesBlocksId\": 0}}}');");
$this->addSql("INSERT INTO `std_pages_pages` (`page_id`, `relation_id`, `order_value`, `content_type`) VALUES (@childpage, @id_home_page_relation, 1, @privatearea_contenttype);");
$this->addSql("SET @id_personal_data_relation = (SELECT id FROM `std_pages_pages` WHERE `page_id` = @childpage);");
$this->addSql("INSERT INTO `std_friendly_url` (`page_id`, `url`, `relation_tree`, `relation_id`, `language_code`, `is_canonical`) VALUES (@childpage, '/pt/moradas', '[]', NULL, 'pt', 0);");
$this->addSql("INSERT INTO `std_friendly_url` (`page_id`, `url`, `relation_tree`, `relation_id`, `language_code`, `is_canonical`) VALUES (@childpage, '/pt/area-reservada/moradas', CONCAT('{\"url\": \"/moradas\", \"relation_id\": ',@id_home_page_relation,'}'), @id_personal_data_relation, 'pt', 1);");
$this->addSql("INSERT INTO std_page_web_role(page_id,webrole_id)VALUES(@childpage,@default_webrole);");
//Create pt menu entry
$this->addSql("SET @menu_content_type = (SELECT id FROM std_content_types WHERE machine_name='menus');");
$this->addSql("SET @menu_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Menu área reservada');");
$this->addSql("SET @menu_page_relation = (SELECT id FROM std_pages_pages WHERE `page_id`=@menu_page);");
$this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_contenttype AND name='Moradas');");
$this->addSql("SET @child_page_canonical = (SELECT id FROM std_friendly_url WHERE `page_id`=@child_page AND is_canonical=1);");
$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, 'Moradas');");
$this->addSql("SET @menu_child_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Moradas');");
$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(), 'Moradas', 'moradas', NULL, '', '', '', '', '', '', '', '', '', '', CONCAT('{\"id\": ',@child_page,', \"target\": \"_self\", \"relationId\": 0}'));");
$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);");
$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);");
$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);");
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("SET @privatearea_contenttype = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
$this->addSql("SET @menu_content_type = (SELECT id FROM std_content_types WHERE machine_name='menus');");
$this->addSql("SET @menu_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Menu área reservada');");
$this->addSql("SET @menu_page_relation = (SELECT id FROM std_pages_pages WHERE `page_id`=@menu_page);");
$this->addSql("SET @menu_child_page = (SELECT id FROM std_pages WHERE `content_type`=@menu_content_type AND name='Moradas');");
$this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_contenttype AND name='Moradas');");
$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;");
$this->addSql("DELETE FROM `std_pages_pages` WHERE `page_id`=@menu_child_page AND `relation_id`=@menu_page_relation;");
$this->addSql("DELETE FROM `std_pages_pages` WHERE `page_id`=@child_page AND `relation_id`=@menu_page_relation;");
$this->addSql("DELETE FROM `std_pages_content` WHERE `page_id`=@menu_child_page;");
$this->addSql("DELETE FROM `std_pages` WHERE `id`=@menu_child_page;");
$this->addSql("SET @pageid = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_contenttype AND `name`='Moradas');");
$this->addSql("DELETE FROM `std_friendly_url` WHERE page_id =@pageid;");
$this->addSql("DELETE FROM `std_pages_pages` WHERE page_id =@pageid;");
$this->addSql("DELETE FROM `std_page_web_role` WHERE page_id =@pageid;");
$this->addSql("DELETE FROM `std_pages_content` WHERE page_id =@pageid;");
$this->addSql("DELETE FROM `std_favorite_pages_users` WHERE page_id =@pageid;");
$this->addSql("DELETE FROM `std_menus_friendly_url` WHERE page_id =@pageid;");
$this->addSql("DELETE FROM `std_page_web_role` WHERE page_id =@pageid;");
$this->addSql("DELETE FROM `std_pages` WHERE id=@pageid;");
$this->addSql("SET @id_block = (SELECT id FROM `std_blocks` WHERE `machine_name` = 'web_users_addresses');");
$this->addSql("DELETE FROM `std_blocks_components` WHERE `block_id` = @id_block AND `machine_name` = 'title';");
$this->addSql("DELETE FROM `std_blocks_components` WHERE `block_id` = @id_block AND `machine_name` = 'addnew';");
$this->addSql("DELETE FROM `std_blocks_settings` WHERE `block_id` = @id_block AND `machine_name` = 'disabled_block';");
$this->addSql("DELETE FROM `std_blocks` WHERE `machine_name` = 'web_users_addresses';");
}
}