migrations/Version20220117122001.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 Version20220117122001 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         $this->addSql("
  18.         INSERT INTO `std_blocks` (`created_by`, `updated_by`, `machine_name`, `is_active`, `created_date`, `updated_date`, `name`, `settings`) 
  19.         VALUES (1, 1, 'B30_mosaic', 1, now(), now(), 'Mosaic', '{\"webpackEntries\": [\"B30_mosaic\"]}');
  20.         ");
  21.         //Settings
  22.          $this->addSql("
  23.          SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B30_mosaic');    
  24.              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 
  25.              ('disabled_block', @block_id, 1, 1, 'Disabled block', 'CHECKBOX', 1, now(), now(), -1, NULL),
  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.              ('container', @block_id, '1', '1', 'Inside Container', 'CHECKBOX', '1', now(), now(), '7', NULL),
  33.              ('gap', @block_id, 1, 1, 'Gap', 'INPUT', 1, now(), now(), 8, NULL);
  34.         ");
  35.         //Components
  36.         $this->addSql("
  37.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B30_mosaic');
  38.         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 
  39.         ('image', @block_id, '1', '1', 'IMAGE', NULL, '2', now(), now(), 'Image', '1'),
  40.         ('text', @block_id, '1', '1', 'TEXTAREA', NULL, '4', now(), now(), 'Text', '1'),
  41.         ('h_columns', @block_id, '1', '1', 'COMBO', '{\"data\": [{\"One\": \"1\"}, {\"Two\": \"2\"}, {\"Three\": \"3\"}, {\"Four\": \"4\"}], \"type\": \"static\", \"default\": \"1\"}', '5', now(), now(), 'Horizontal Columns', '1'),
  42.         ('v_rows', @block_id, '1', '1', 'COMBO', '{\"data\": [{\"One\": \"1\"}, {\"Two\": \"2\"}, {\"Three\": \"3\"}, {\"Four\": \"4\"}], \"type\": \"static\", \"default\": \"1\"}', '6', now(), now(), 'Vertical Rows', '1'),
  43.         ('image_filter', @block_id, 1, 1, 'COMBO', '{\"data\": [{\"0%\": \"opacity-0\"}, {\"30%\": \"opacity-30\"}, {\"50%\": \"opacity-50\"}, {\"70%\": \"opacity-70\"}], \"type\": \"static\", \"render\": true, \"default\": \"opacity-30\"}', 3, now(), now(), 'Image filter', '1');
  44.         ");
  45.     }
  46.     public function down(Schema $schema) : void
  47.     {
  48.         // this down() migration is auto-generated, please modify it to your needs
  49.         $this->addSql("
  50.             SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B30_mosaic');  
  51.               DELETE FROM `std_blocks_components` where machine_name IN ('h_columns','v_rows','image','image_filter','text') and `block_id`= @block_id;
  52.               DELETE FROM `std_blocks_settings` where machine_name IN ('disabled_block','separator_styles','extra_block_id','extra_class','separator_spacings','margin','padding','container','gap') and `block_id`= @block_id;
  53.               DELETE FROM `std_blocks` where machine_name = 'B30_mosaic';
  54.         ");
  55.     }
  56. }