migrations/Version20210909140735.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 Version20210909140735 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, 'B10_hotspot', 1, now(), now(), 'Hotspot', '{\"webpackEntries\": [\"hotspot\"]}');
  21.         ");
  22.         //Settings
  23.          $this->addSql("
  24.          SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B10_hotspot');    
  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 @CT_id=(SELECT id FROM std_content_types WHERE machine_name='pages');
  37.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B10_hotspot');
  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.             ('hotspot_image', @block_id, '1', '1', 'HOTSPOT', NULL, '3', now(), now(), 'Hotspot Image', 0),
  40.             ('icon', @block_id, 1, 1, 'COMBO', '{\"data\": [{\"Default\": \"skin_1\"}, {\"Skin 2\": \"skin_2\"}], \"type\": \"static\", \"render\": false, \"default\": \"skin_1\"}', 4, now(), now(), 'Icon', 1),
  41.             ('title', @block_id, '1', '1', 'INPUT', '{\"render\": false}', '5', now(), now(), 'Title', '1'),
  42.             ('text', @block_id, '1', '1', 'TEXTAREA', '{\"render\": false}', '6', now(), now(), 'Text', '1'),
  43.             ('image', @block_id, '1', '1', 'IMAGE', '{\"render\": false}', '7', now(), now(), 'Image', '1'),
  44.             ('label', @block_id, '1', '1', 'INPUT', '{\"render\": false}', '7', now(), now(), 'Label button', '1'),
  45.             ('link', @block_id, 1, 1, 'COMBO_PAGES', CONCAT('{\"render\": false, \"content_type\":\"',@CT_id,'\"}'), '10', now(),  now(), 'Link',1);
  46.         ");
  47.     }
  48.     public function down(Schema $schema) : void
  49.     {
  50.         $this->addSql("
  51.             SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B10_hotspot'); 
  52.                 DELETE FROM `std_blocks_components` WHERE block_id = @block_id;
  53.                 DELETE FROM `std_blocks_settings` WHERE block_id = @block_id;
  54.                 DELETE FROM `std_blocks` where machine_name= 'B10_hotspot';
  55.         ");
  56.     }
  57. }