migrations/Version20230613084143.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 Version20230613084143 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("SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='web_users_detail');");
  19.         $this->addSql("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 
  20.             ('show_erp_code', @block_id, '1', '1', 'CHECKBOX', null , 87, now(), now(), 'Mostrar código ERP?', 0)
  21.         ;");
  22.         $this->addSql("SET @privatearea_content_type = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
  23.         $this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_content_type AND name='Dados pessoais');");
  24.         $this->addSql("UPDATE std_pages_content 
  25.         SET content = 
  26.             JSON_SET(content,
  27.                 concat(REPLACE(
  28.                     JSON_UNQUOTE(
  29.                         JSON_SEARCH(content, 'one', 'web_users_detail')
  30.                     ),'block',''),
  31.                 'components.show_erp_code'),
  32.             '0')
  33.         WHERE page_id = @child_page;");
  34.         
  35.         $this->addSql("SET @privatearea_content_type = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
  36.         $this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_content_type AND name='Área reservada');");
  37.         $this->addSql("UPDATE std_pages_content 
  38.         SET content = 
  39.             JSON_SET(content,
  40.                 concat(REPLACE(
  41.                     JSON_UNQUOTE(
  42.                         JSON_SEARCH(content, 'one', 'web_users_detail')
  43.                     ),'block',''),
  44.                 'components.show_erp_code'),
  45.             '0')
  46.         WHERE page_id = @child_page;");
  47.         
  48.     }
  49.     public function down(Schema $schema): void
  50.     {
  51.         // this down() migration is auto-generated, please modify it to your needs
  52.         $this->addSql("SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='web_users_detail');");
  53.         $this->addSql("DELETE FROM `std_blocks_components` WHERE `block_id`=@block_id 
  54.         AND `machine_name` IN('show_erp_code');");
  55.         $this->addSql("SET @privatearea_content_type = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
  56.         $this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_content_type AND name='Dados pessoais');");
  57.         $this->addSql("UPDATE std_pages_content 
  58.         SET content = JSON_REMOVE(content, 
  59.             concat(
  60.                 REPLACE(
  61.                     JSON_UNQUOTE(
  62.                         JSON_SEARCH(content, 'one', 'web_users_detail')
  63.                     ),'block',''),
  64.                 'components.show_erp_code'))
  65.         WHERE page_id = @child_page;");
  66.         $this->addSql("SET @privatearea_content_type = (SELECT id FROM std_content_types WHERE machine_name='private_area');");
  67.         $this->addSql("SET @child_page = (SELECT id FROM std_pages WHERE `content_type`=@privatearea_content_type AND name='Área reservada');");
  68.         $this->addSql("UPDATE std_pages_content 
  69.         SET content = JSON_REMOVE(content, 
  70.             concat(
  71.                 REPLACE(
  72.                     JSON_UNQUOTE(
  73.                         JSON_SEARCH(content, 'one', 'web_users_detail')
  74.                     ),'block',''),
  75.                 'components.show_erp_code'))
  76.         WHERE page_id = @child_page;");
  77.     }
  78. }