migrations/Version20220223145703.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 Version20220223145703 extends AbstractMigration
  10. {
  11.     public $name "Timeline";
  12.     public $machinename "B33_timeline";
  13.     public function getDescription(): string
  14.     {
  15.         return '';
  16.     }
  17.     public function up(Schema $schema): void
  18.     {
  19.         // this up() migration is auto-generated, please modify it to your needs
  20.         $this->addSql("
  21.         INSERT INTO `std_blocks` 
  22.             (`created_by`, `updated_by`, `machine_name`, `is_active`, `created_date`, `updated_date`, `name`, `settings`) 
  23.             VALUES
  24.                 (1, 1, '$this->machinename', 1, now(), now(), '$this->name', '{\"webpackEntries\": [\"B33_timeline\", \"slick-carousel\"]}');
  25.         ");
  26.         $this->addSql("
  27.         SET @block_id = (SELECT id FROM std_blocks WHERE machine_name = '$this->machinename');
  28.         ");
  29.         $this->addSql("  
  30.         INSERT INTO `std_blocks_settings` 
  31.             (`machine_name`, `block_id`, `created_by`, `updated_by`, `name`, `setting_type`, `is_active`, `created_date`, `updated_date`, `order_value`, `settings`) 
  32.             VALUES 
  33.                 ('disabled_block', @block_id, 1, 1, 'Disabled block', 'CHECKBOX', 1, now(), now(), '-1', NULL),
  34.                 ('offset', @block_id, 1, 1, 'Offset', 'CHECKBOX', 1, now(), now(), '1', NULL),
  35.                 ('separator_styles', @block_id, '1', '1', 'Styles', 'SEPARATOR', '1', now(), now(), '2', NULL),
  36.                 ('extra_block_id', @block_id, '1', '1', 'Block ID', 'INPUT', '1', now(), now(), '3', NULL),
  37.                 ('extra_class', @block_id, '1', '1', 'Extra Class', 'INPUT', '1', now(), now(), '4', NULL),
  38.                 ('separator_spacings', @block_id, '1', '1', 'Spacings', 'SEPARATOR', '1', now(), now(), '5', NULL),
  39.                 ('margin', @block_id, '1', '1', 'Margin [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '6', NULL),
  40.                 ('padding', @block_id, '1', '1', 'Padding [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '7', NULL);
  41.         ");
  42.         $this->addSql("
  43.         INSERT INTO `std_blocks_components` 
  44.             (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) 
  45.             VALUES
  46.                 ('item_date', @block_id, 1, 1, 'INPUT', NULL, 1, 1, now(), now(), 'Item Date', 1),
  47.                 ('item_title', @block_id, 1, 1, 'TEXTAREA', NULL, 2, 1, now(), now(), 'Item Title', 1),
  48.                 ('item_text', @block_id, 1, 1, 'TEXTAREA', NULL, 3, 1, now(), now(), 'Item Text', 1),
  49.                 ('item_image', @block_id, 1, 1, 'IMAGE', NULL, 4, 1, now(), now(), 'Item Image', 1);
  50.         ");
  51.     }
  52.     public function down(Schema $schema): void
  53.     {
  54.         // this down() migration is auto-generated, please modify it to your needs
  55.         $this->addSql("
  56.         SET @block_id = (SELECT id FROM std_blocks WHERE machine_name = '$this->machinename');
  57.         DELETE FROM `std_blocks_components` WHERE  `block_id` = @block_id;
  58.         DELETE FROM `std_blocks_settings` WHERE `block_id`= @block_id;
  59.         DELETE FROM `std_blocks` WHERE  `id` = @block_id;
  60.         ");
  61.     }
  62. }