migrations/Version20210113121421.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 Version20210113121421 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         // Create Web Role DEFAULT"
  18.         $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());");
  19.         $this->addSql("SET @id_default_web_role = (SELECT id FROM `std_web_roles` WHERE `is_default` = 1 LIMIT 1);");
  20.         // Create block "Web User Detail"
  21.         $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}');");
  22.         $this->addSql("SET @id_block = (SELECT id FROM `std_blocks` WHERE `machine_name` = 'web_users_detail');");
  23.         $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);");
  24.         // new content type for private area
  25.         $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`)
  26.                                                 VALUES ('Private area', 'private_area', 1, 1, Now(), 1, Now(), 'private_area', 1);");
  27.         
  28.         $this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'private_area');");
  29.         // Create page "Private Area (Home)"
  30.         $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`)
  31.                                             VALUES (NULL, 1, 1, @id_content_type, 1, NOW(), NOW(), NULL, NOW(), NULL, 'Área reservada');");
  32.         $this->addSql("SET @id_home_page = (SELECT id FROM `std_pages` WHERE `content_type` = @id_content_type AND `name`='Área reservada');");
  33.         $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`)
  34.                                             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}}}');");
  35.         // $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`)
  36.         //                                     VALUES (@id_home_page, 'en', 1, 1, 1, NOW(), NOW(), 'Private area', 'private-area', '/en/private-area', '', '', '', '', '', '', '', '', '', '', '[]');");
  37.         $this->addSql("INSERT INTO `std_pages_pages` (`page_id`, `relation_id`, `order_value`, `content_type`) VALUES (@id_home_page, 0, 1, @id_content_type);");
  38.         $this->addSql("SET @id_home_page_relation = (SELECT id FROM `std_pages_pages` WHERE `page_id` = @id_home_page);");
  39.         $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);");
  40.         // $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);");
  41.         $this->addSql("INSERT INTO std_page_web_role(page_id,webrole_id)VALUES(@id_home_page,@id_default_web_role);");
  42.     }
  43.     public function down(Schema $schema) : void
  44.     {
  45.         $this->addSql("SET @id_content_type = (SELECT id FROM `std_content_types` WHERE `machine_name` = 'private_area');");
  46.         $this->addSql("DELETE FROM `std_friendly_url` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
  47.         $this->addSql("DELETE FROM `std_pages_pages` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
  48.         $this->addSql("DELETE FROM `std_page_web_role` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
  49.         $this->addSql("DELETE FROM `std_pages_content` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
  50.         $this->addSql("DELETE FROM `std_favorite_pages_users` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
  51.         $this->addSql("DELETE FROM `std_menus_friendly_url` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
  52.         $this->addSql("DELETE FROM `std_page_web_role` WHERE page_id IN(SELECT id FROM std_pages WHERE `content_type`=@id_content_type);");
  53.         $this->addSql("DELETE FROM `std_pages` WHERE `content_type`=@id_content_type;");
  54.         $this->addSql("DELETE FROM `std_content_types` WHERE `machine_name`='private_area';");
  55.         // Delete block "Web User Detail"
  56.         $this->addSql("SET @id_block = (SELECT id FROM `std_blocks` WHERE `machine_name` = 'web_users_detail');");
  57.         $this->addSql("DELETE FROM `std_blocks_components` WHERE `block_id` = @id_block AND `machine_name` = 'title';");
  58.         $this->addSql("DELETE FROM `std_blocks` WHERE `machine_name` = 'web_users_detail';");
  59.         // Delete Web Role DEFAULT"
  60.         $this->addSql("DELETE FROM std_page_web_role WHERE webrole_id IN(SELECT id FROM `std_web_roles` WHERE `is_default` = 1);");
  61.         $this->addSql("DELETE FROM `std_web_roles` WHERE `is_default` = 1;");
  62.     }
  63. }