migrations/Version20210420105652.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 Version20210420105652 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, 'B06_image_text', 1, now(), now(), 'Image Text', '{\"webpackEntries\": [\"image_text\"]}');
  21.         ");
  22.         //Settings
  23.          $this->addSql("
  24.          SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B06_image_text');    
  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.              ('separator_styles', @block_id, '1', '1', 'Styles', 'SEPARATOR', '1', now(), now(), '1', NULL),
  27.              ('extra_block_id', @block_id, '1', '1', 'Block ID', 'INPUT', '1', now(), now(), '2', NULL),
  28.              ('extra_class', @block_id, '1', '1', 'Extra Class', 'INPUT', '1', now(), now(), '3', NULL),
  29.              ('separator_spacings', @block_id, '1', '1', 'Spacings', 'SEPARATOR', '1', now(), now(), '4', NULL),
  30.              ('margin', @block_id, '1', '1', 'Margin [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '5', NULL),
  31.              ('padding', @block_id, '1', '1', 'Padding [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '6', NULL);
  32.         ");
  33.         //Components
  34.         $this->addSql("
  35.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B06_image_text');
  36.             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 
  37.             ('title', @block_id, '1', '1', 'TEXTAREA', '{\"ckeditor\": \"title\"}', '1', now(), now(), 'Title', '1'),           
  38.             ('text', @block_id, '1', '1', 'TEXTAREA', NULL, '2', now(), now(), 'Text', '1'),           
  39.             ('textcolor', @block_id, '1', '1', 'COLORPICKER', NULL, '3', now(), now(), 'Text color', '1'),           
  40.             ('bgcolor', @block_id, '1', '1', 'COLORPICKER', NULL, '4', now(), now(), 'Background color', '1'),           
  41.             ('image', @block_id, '1', '1', 'IMAGE', NULL, '5', now(), now(), 'Image', '1'),           
  42.             ('image_position', @block_id, '1', '1', 'CHECKBOX', NULL, '6', now(), now(), 'Image on the right', '1'),           
  43.             ('label_bt', @block_id, '1', '1', 'INPUT', NULL, '7', now(), now(), 'Label button', '1'),         
  44.             ('url', @block_id, '1', '1', 'INPUT', NULL, '8', now(), now(), 'URL', '1'),         
  45.             ('page', @block_id, '1', '1', 'COMBO', '{\"sql\": \"SELECT p.id AS codigo, p.name AS descricao FROM std_pages p WHERE p.content_type IN(SELECT id FROM std_content_types WHERE machine_name IN(\\'pages\\',\\'pages_categories\\',\\'sytem\\')) ORDER BY p.name\", \"type\": \"dynamic\", \"isMultiple\": \"false\"}', '9', now(), now(), 'Category / Page', '1'),
  46.             ('target', @block_id, 1, 1, 'COMBO', '{\"data\": [{\"Self\": \"_self\"}, {\"New Page\": \"_blank\"}], \"type\": \"static\", \"default\": \"_self\"}', 10, now(), now(), 'Target', 1);
  47.         ");
  48.         //skins
  49.         $this->addSql("
  50.          SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B06_image_text');    
  51.          INSERT INTO `std_blocks_skins` (`block_id`, `machine_name`, `name`, `is_active`, `created_by`, `created_date`, `updated_by`, `updated_date`) 
  52.          VALUES (@block_id, 'columns_4', '4 columns', 1, 1, now(), 1, now());
  53.          INSERT INTO `std_blocks_skins` (`block_id`, `machine_name`, `name`, `is_active`, `created_by`, `created_date`, `updated_by`, `updated_date`) 
  54.          VALUES (@block_id, 'columns_2', '2 columns', 1, 1, now(), 1, now());
  55.          
  56.          INSERT INTO `std_blocks_skins` (`block_id`, `machine_name`, `name`, `is_active`, `created_by`, `created_date`, `updated_by`, `updated_date`) 
  57.          VALUES (@block_id, 'text_image50', '50% 50% ', 1, 1, now(), 1, now());
  58.         ");
  59.     }
  60.     public function down(Schema $schema) : void
  61.     {
  62.         // this down() migration is auto-generated, please modify it to your needs
  63.         $this->addSql("
  64.             SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B06_image_text'); 
  65.               DELETE FROM `std_blocks_components` where machine_name IN ('title','text','textcolor','bgcolor','image','image_position','label_bt','url','page','target') and `block_id`= @block_id;
  66.               DELETE FROM `std_blocks_settings` where machine_name IN ('separator_styles','extra_block_id','extra_class','separator_spacings','margin','padding') and `block_id`= @block_id;
  67.               DELETE FROM `std_blocks` where machine_name = 'B06_image_text';
  68.               DELETE FROM `std_blocks_skins` WHERE  `block_id`=@block_id AND machine_name IN ('columns_4','columns_2','text_image50');
  69.         ");
  70.     }
  71. }