migrations/Version20220215140936.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 Version20220215140936 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 IGNORE INTO `std_blocks` 
  19.             (`created_by`, `updated_by`, `machine_name`, `is_active`, `created_date`, `updated_date`, `name`, `settings`) 
  20.             VALUES 
  21.                 (1, 1, 'form_text', 1, NOW(), NOW(), 'Form text', '{\"isCacheable\": false}');
  22.         ");
  23.         $this->addSql("
  24.         SET @contentType_id=(SELECT id FROM std_content_types WHERE machine_name='forms');
  25.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='form_text');
  26.         INSERT IGNORE INTO `std_content_types_blocks` 
  27.             (`content_type`, `block_id`) 
  28.             VALUES 
  29.                 (@contentType_id, @block_id);
  30.         ");
  31.         $this->addSql("
  32.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='form_text');
  33.         INSERT IGNORE INTO `std_blocks_components` 
  34.             (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) 
  35.             VALUES 
  36.                 ('form_item_text', @block_id, 1, 1, 'TEXTAREA', '{\"ckeditor\": \"title\"}', 1, 1, NOW(), NOW(), 'item_text', 0);
  37.         ");
  38.         $this->addSql("
  39.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='form_text');    
  40.         INSERT IGNORE INTO `std_blocks_settings` 
  41.             (`machine_name`, `block_id`, `created_by`, `updated_by`, `name`, `setting_type`, `is_active`, `created_date`, `updated_date`, `order_value`, `settings`) 
  42.             VALUES 
  43.                 ('separator_styles', @block_id, '1', '1', 'Styles', 'SEPARATOR', '1', now(), now(), '1', NULL),
  44.                 ('extra_block_id', @block_id, '1', '1', 'Block ID', 'INPUT', '1', now(), now(), '2', NULL),
  45.                 ('extra_class', @block_id, '1', '1', 'Extra Class', 'INPUT', '1', now(), now(), '3', NULL),
  46.                 ('offset', @block_id, '1', '1', 'Offset', 'CHECKBOX', '1', now(), now(), '4', NULL),
  47.                 ('separator_spacings', @block_id, '1', '1', 'Spacings', 'SEPARATOR', '1', now(), now(), '5', NULL),
  48.                 ('margin', @block_id, '1', '1', 'Margin [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '6', NULL),
  49.                 ('padding', @block_id, '1', '1', 'Padding [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '7', NULL);
  50.         ");
  51.     }
  52.     public function down(Schema $schema) : void
  53.     {
  54.         $this->addSql("
  55.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='form_text');
  56.         DELETE FROM `std_blocks_settings` where `block_id`= @block_id;
  57.         ");
  58.         $this->addSql("
  59.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='form_text');
  60.         DELETE FROM `std_blocks_components` WHERE `block_id` = @block_id;
  61.         ");
  62.         $this->addSql("
  63.         SET @contentType_id=(SELECT id FROM std_content_types WHERE machine_name='forms');
  64.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='form_text');
  65.         DELETE FROM `std_content_types_blocks` WHERE `content_type` = @contentType_id AND `block_id` = @block_id;
  66.         ");
  67.         $this->addSql("
  68.         DELETE FROM `std_blocks` WHERE `machine_name` = 'form_text';
  69.         ");
  70.     }
  71. }