app/DoctrineMigrations/Version20231012013206.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 Version20231012013206 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.          $sql 'SELECT `id` FROM `dtb_block` ORDER BY `id` DESC LIMIT 1';
  19.          $results $this->connection->fetchAssociative($sql);
  20.          $lastId = (int) $results["id"] + 1;
  21.          $checkBlockSql 'SELECT `id` FROM `dtb_block` WHERE block_name = "History Product"';
  22.          $isBlockExist  $this->connection->fetchAssociative($checkBlockSql);
  23.          $insert_block "INSERT INTO dtb_block (id, device_type_id, block_name, file_name, use_controller, deletable, create_date, update_date, discriminator_type) VALUES ";
  24.          if (!$isBlockExist) {
  25.              $this->addSql($insert_block "($lastId ,10, 'History Product', 'history_product', 0, 1, '2023-10-12 04:00:21', '2023-10-12 04:00:21', 'block');");
  26.          }
  27.      }
  28.  
  29.      public function down(Schema $schema): void
  30.      {
  31.          // this down() migration is auto-generated, please modify it to your needs
  32.          $sql 'SELECT `id` FROM `dtb_block` WHERE block_name = "History Product"';
  33.          $results $this->connection->fetchAssociative($sql);
  34.          if ($results) {
  35.              $this->addSql('DELETE FROM dtb_block_position WHERE block_id = ?',[(int)$results["id"]]);
  36.              $this->addSql('DELETE FROM dtb_block WHERE block_name = "History Product"');
  37.          }
  38.      }
  39. }