migrations/Version20220127091547.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 Version20220127091547 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql("
  19.             INSERT INTO `std_blocks` (`created_by`, `updated_by`, `machine_name`, `is_active`, `created_date`, `updated_date`, `name`, `settings`) 
  20.             VALUES (1, 1, 'B32_newsletter', 1, now(), now(), 'Newsletter', '{\"webpackEntries\": [\"B32_newsletter\",\"validation_messages_%locale%\"]}');
  21.         ");
  22.         //Settings
  23.          $this->addSql("
  24.          SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B32_newsletter');    
  25.              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 
  26.              ('disabled_block', @block_id, 1, 1, 'Disabled block', 'CHECKBOX', 1, now(), now(), -1, NULL),
  27.              ('separator_styles', @block_id, '1', '1', 'Styles', 'SEPARATOR', '1', now(), now(), '1', NULL),
  28.              ('extra_block_id', @block_id, '1', '1', 'Block ID', 'INPUT', '1', now(), now(), '2', NULL),
  29.              ('extra_class', @block_id, '1', '1', 'Extra Class', 'INPUT', '1', now(), now(), '3', NULL),
  30.              ('separator_spacings', @block_id, '1', '1', 'Spacings', 'SEPARATOR', '1', now(), now(), '4', NULL),
  31.              ('margin', @block_id, '1', '1', 'Margin [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '5', NULL),
  32.              ('padding', @block_id, '1', '1', 'Padding [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '6', NULL);
  33.         ");
  34.         //Components
  35.         $this->addSql("
  36.             SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B32_newsletter');
  37.             INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES 
  38.             ('title', @block_id, '1', '1', 'INPUT', NULL, '1', now(), now(), 'Title', '0'),
  39.             ('placeholder', @block_id, '1', '1', 'INPUT', NULL, '2', now(), now(), 'placeholder', '0'),
  40.             ('btn', @block_id, '1', '1', 'INPUT', NULL, '3', now(), now(), 'Label bt', '0'),
  41.             ('privacy', @block_id, '1', '1', 'INPUT', NULL, '4', now(), now(), 'Label privacy', '0'),
  42.             ('service', @block_id, 1, 1, 'COMBO', '{\"data\": [{\"Mailchimp\": \"mailchimp\"}, {\"E-goi\": \"egoi\"}], \"type\": \"static\", \"default\": \"mailchimp\"}', '5', now(), now(), 'Service', '0'),
  43.             ('mailchimpurl', @block_id, '1', '1', 'INPUT', NULL, '6', now(), now(), 'Mailchimp url', '0'),
  44.             ('egoilist', @block_id, '1', '1', 'INPUT', NULL, '7', now(), now(), 'E-goi list', '0'),
  45.             ('servicehtmlcode', @block_id, '1', '1', 'TEXTAREA_HTML', NULL, '11', now(), now(), 'Service html code', '0'); 
  46.         ");
  47.                                                             
  48.          $this->addSql("
  49.             SET @id_ct_system=(SELECT id FROM std_content_types WHERE machine_name='system');
  50.             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`,`layout`) VALUES 
  51.             (NULL, 1, 1, @id_ct_system, 1, now(), now(), NULL, now(), NULL,'Newsletter', NULL);
  52.             SET @id_page_newsletter = LAST_INSERT_ID();     
  53.             INSERT INTO `std_pages_content` (`page_id`, `language_code`, `created_by`, `updated_by`, `is_active`, `created_date`, `updated_date`, `title`, `url`, `canonical_url`, `content`) VALUES 
  54.             (@id_page_newsletter, 'pt', 1, 1, 1, now(), now(), 'Newsletter', 'newsletter', '/pt/bloco-newsletter', '{\"fields\": {\"1\": {\"skin\": \"\", \"block\": \"B32_newsletter\", \"isMaster\": 0, \"settings\": {\"margin\": \"\", \"padding\": \"\", \"expire_date\": \"\", \"extra_class\": \"\", \"publish_date\": \"\", \"disabled_block\": \"0\", \"extra_block_id\": \"\"}, \"blockname\": \"\", \"components\": {\"btn\": \"Subscrever\", \"title\": \"Subscrever newsletter\", \"privacy\": \"Concordo com os \", \"service\": \"mailchimp\", \"egoilist\": \"\", \"placeholder\": \"Insira o seu email\", \"mailchimpurl\": \"\", \"servicehtmlcode\": \"\"}, \"repeatable\": [], \"templatesBlocksId\": 0}}}');              
  55.             INSERT INTO `std_pages_pages` VALUES (NULL,@id_page_newsletter, 0, 1, @id_ct_system);
  56.             
  57.             INSERT INTO `std_friendly_url` (`page_id`, `url`, `relation_tree`, `relation_id`, `language_code`, `is_canonical`) 
  58.             VALUES (@id_page_newsletter, '/pt/newsletter', '[]', NULL, 'pt', 1);
  59.             INSERT INTO `std_config` (`machine_name`, `created_by`, `updated_by`, `value`, `description_machine_name`, `details_machine_name`, `parent_name`, `variable_type`, `order_value`, `is_hidden`, `is_active`, `created_date`, `updated_date`, `label`, `content`, `language_code`) VALUES 
  60.             ('newsletterblock_page', 1, 1, '', 'newsletterblock_page', 'newsletterblock_page', 'Newsletter', 'SELECT', 1, 0, 1, NOW(), NOW(), 'Newsletter page', '{\"query\": \"select p.`name` as label,p.id as id from std_pages p INNER JOIN std_content_types sct ON p.content_type = sct.id  where sct.machine_name IN ( \'system\')\"}', '');
  61.             INSERT INTO `std_config` (`machine_name`, `created_by`, `updated_by`, `value`, `description_machine_name`, `details_machine_name`, `parent_name`, `variable_type`, `order_value`, `is_hidden`, `is_active`, `created_date`, `updated_date`, `label`, `content`, `language_code`) VALUES 
  62.             ('egoiapikey', 1, 1, '', 'egoiapikey', 'egoiapikey', 'Newsletter', 'INPUT', 2, 0, 1, NOW(), NOW(), 'E-goi API key', NULL, '');
  63.          "); 
  64.          
  65.     }
  66.     public function down(Schema $schema) : void
  67.     {
  68.         // this down() migration is auto-generated, please modify it to your needs
  69.         $this->addSql("
  70.             SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B32_newsletter');  
  71.               DELETE FROM `std_blocks_components` where machine_name IN ('title','placeholder','btn','privacy','service','mailchimpurl','egoilist','servicehtmlcode') and `block_id`= @block_id;
  72.               DELETE FROM `std_blocks_settings` where machine_name IN ('disabled_block','separator_styles','extra_block_id','extra_class','separator_spacings','margin','padding') and `block_id`= @block_id;
  73.               DELETE FROM `std_blocks` where machine_name = 'B32_newsletter';
  74.         ");
  75.         $this->addSql("
  76.             SET @id_page_newsletterblock = (SELECT id FROM std_pages WHERE name='newsletter'); 
  77.             DELETE FROM `std_config` where machine_name IN ('newsletterblock_page','egoiapikey');
  78.             DELETE FROM `std_friendly_url` where page_id = @id_page_newsletterblock;
  79.             DELETE FROM `std_pages_content` where page_id = @id_page_newsletterblock;
  80.             DELETE FROM `std_pages_pages` where page_id = @id_page_newsletterblock;
  81.             DELETE FROM `std_pages` where id = @id_page_newsletterblock;
  82.         ");
  83.     }
  84. }