migrations/Version20210921155827.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 Version20210921155827 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`) VALUES
  19.         (1, 1, 'form_radio', 1, now(), now(), 'Form radio', NULL);
  20.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='form_radio');
  21.         INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES 
  22.             ('form_input_name', @block_id, 1, 1, 'INPUT', NULL, 1, 1, now(), now(), 'input_name', 0),
  23.             ('form_input_label', @block_id, 1, 1, 'INPUT', NULL, 2, 1, now(), now(), 'input_label', 0),
  24.             ('form_input_required_label', @block_id, 1, 1, 'INPUT', NULL, 3, 1, now(), now(), 'input_required_label', 0),
  25.             ('form_radio_name', @block_id, 1, 1, 'INPUT', NULL, 4, 1, now(), now(), 'input_name', 1),
  26.             ('form_radio_label', @block_id, 1, 1, 'INPUT', NULL, 5, 1, now(), now(), 'input_label', 1),
  27.             ('form_checked', @block_id, 1, 1, 'CHECKBOX', NULL, 6, 1, now(), now(), 'Ligado por defeito', 1);
  28.         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`)
  29.         VALUES 
  30.             ('form_required', @block_id, 1, 1, 'Required', 'CHECKBOX', 1, now(), now(), 1, NULL),
  31.             ('setting_form_cols', @block_id, 1, 1, 'Form cols', 'INPUT', 1, now(), now(), 1, NULL);
  32.         SET @content_type_id=(SELECT id FROM std_content_types WHERE machine_name='forms');
  33.         INSERT INTO `std_content_types_blocks` (`content_type`, `block_id`) VALUES (@content_type_id, @block_id);
  34.         ");
  35.     }
  36.     public function down(Schema $schema) : void
  37.     {
  38.         $this->addSql("
  39.         SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='form_radio'); 
  40.             DELETE FROM `std_blocks_components` WHERE block_id = @block_id;
  41.             DELETE FROM `std_blocks_settings` WHERE block_id = @block_id;
  42.             DELETE FROM `std_content_types_blocks` WHERE block_id = @block_id;
  43.             DELETE FROM `std_blocks` WHERE id = @block_id;
  44.         ");
  45.     }
  46. }