<?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 Version20210113121421 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// Create Web Role DEFAULT"
$this->addSql("INSERT INTO `std_web_roles` (`created_by`, `updated_by`, `name`, `image`, `is_active`, `is_default`, `created_date`, `updated_date`) VALUES (1, 1, 'DEFAULT', 'Persona1.png', 1, 1, NOW(), NOW());");
$this->addSql("SET @id_default_web_role = (SELECT id FROM `std_web_roles` WHERE `is_default` = 1 LIMIT 1);");
// Create block "Web User Detail"
$this->addSql("INSERT INTO `std_blocks` (`created_by`, `updated_by`, `machine_name`, `created_date`, `updated_date`, `name`, `settings`) VALUES ('1', '1', 'web_users_detail', NOW(), NOW(), 'Dados utilizador', '{\"isWebUserDetail\": true}');");
$this->addSql("SET @id_block = (SELECT id FROM `std_blocks` WHERE `machine_name` = 'web_users_detail');");
$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);");
// new content type for private area
$this->addSql("INSERT INTO `std_content_types` (`name`, `machine_name`, `is_active`, `created_by`, `created_date`, `updated_by`, `updated_date`, `machine_name_categories`, `is_category`)
VALUES ('Private area', 'private_area', 1, 1, Now(), 1, Now(), 'private_area', 1);");
$this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'private_area');");
// Create page "Private Area (Home)"
$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, 'Área reservada');");
$this->addSql("SET @id_home_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Área reservada');");
$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_home_page, 'pt', 1, 1, 1, NOW(), NOW(), 'Área reservada', 'area-reservada', '/pt/area-reservada', '', '', '', '', '', '', '', '', '', '', '{\"fields\": {\"1\": {\"skin\": \"\", \"block\": \"web_users_detail\", \"isMaster\": 0, \"settings\": {\"expire_date\": \"\", \"publish_date\": \"\"}, \"blockname\": \"\", \"components\": {\"title\": \"Os meus dados\"}, \"repeatable\": [], \"templatesBlocksId\": 0}}}');");
// $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_home_page, 'en', 1, 1, 1, NOW(), NOW(), 'Private area', 'private-area', '/en/private-area', '', '', '', '', '', '', '', '', '', '', '[]');");
$this->addSql("INSERT INTO `std_pages_pages` (`page_id`, `relation_id`, `order_value`, `content_type`) VALUES (@id_home_page, 0, 1, @id_content_type);");
$this->addSql("SET @id_home_page_relation = (SELECT id FROM `std_pages_pages` WHERE `page_id` = @id_home_page);");
$this->addSql("INSERT INTO `std_friendly_url` (`page_id`, `url`, `relation_tree`, `relation_id`, `language_code`, `is_canonical`) VALUES (@id_home_page, '/pt/area-reservada', '[]', NULL, 'pt', 1);");
// $this->addSql("INSERT INTO `std_friendly_url` (`page_id`, `url`, `relation_tree`, `relation_id`, `language_code`, `is_canonical`) VALUES (@id_home_page, '/en/private-area', '[]', NULL, 'en', 1);");
$this->addSql("INSERT INTO std_page_web_role(page_id,webrole_id)VALUES(@id_home_page,@id_default_web_role);");
}
public function down(Schema $schema) : void
{
$this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'private_area');");
$this->addSql("DELETE FROM `std_friendly_url` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
$this->addSql("DELETE FROM `std_pages_pages` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
$this->addSql("DELETE FROM `std_page_web_role` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
$this->addSql("DELETE FROM `std_pages_content` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
$this->addSql("DELETE FROM `std_favorite_pages_users` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
$this->addSql("DELETE FROM `std_menus_friendly_url` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
$this->addSql("DELETE FROM `std_page_web_role` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
$this->addSql("DELETE FROM `std_pages` WHERE `content_type`=@id_content_type;");
$this->addSql("DELETE FROM `std_content_types` WHERE `machine_name`='private_area';");
// Delete block "Web User Detail"
$this->addSql("SET @id_block = (SELECT id FROM `std_blocks` WHERE `machine_name` = 'web_users_detail');");
$this->addSql("DELETE FROM `std_blocks_components` WHERE `block_id` = @id_block AND `machine_name` = 'title';");
$this->addSql("DELETE FROM `std_blocks` WHERE `machine_name` = 'web_users_detail';");
// Delete Web Role DEFAULT"
$this->addSql("DELETE FROM std_page_web_role WHERE webrole_id IN(SELECT id FROM `std_web_roles` WHERE `is_default` = 1);");
$this->addSql("DELETE FROM `std_web_roles` WHERE `is_default` = 1;");
}
}