app/DoctrineMigrations/Version20231227034557.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 Version20231227034557 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_page` ORDER BY `id` DESC LIMIT 1';
  19.         $results $this->connection->fetchAssociative($sql);
  20.         $lastId = (int) $results["id"] + 1;
  21.         $insert_page "INSERT INTO dtb_page (id, page_name, url, file_name, edit_type, create_date, update_date, meta_robots, discriminator_type) VALUES ";
  22.         $insert_pagelayout "INSERT INTO dtb_page_layout (page_id, layout_id, discriminator_type) VALUES ";
  23.         $this->addSql($insert_page "($lastId ,'Recommend Product', 'product_recommend', 'Product/recommend', 2, '2023-12-27 17:06:17', '2023-12-27 17:06:17','noindex', 'page');");
  24.         $this->addSql($insert_pagelayout "($lastId ,2 ,'pagelayout');");
  25.         
  26.         $lastId++;
  27.         $this->addSql($insert_page "($lastId ,'New Product', 'new_product', 'Product/new', 2, '2023-12-27 17:06:17', '2023-12-27 17:06:17','noindex', 'page');");
  28.         $this->addSql($insert_pagelayout "($lastId ,2 ,'pagelayout');");
  29.         
  30.         $lastId++;
  31.         $this->addSql($insert_page "($lastId ,'Product Review', 'product_review', 'Product/review', 2, '2023-12-27 17:06:17', '2023-12-27 17:06:17','noindex', 'page');");
  32.         $this->addSql($insert_pagelayout "($lastId ,2 ,'pagelayout');");
  33.         
  34.         $lastId++;
  35.         $this->addSql($insert_page "($lastId ,'Product Contact', 'product_contact', 'Product/contact', 2, '2023-12-27 17:06:17', '2023-12-27 17:06:17','noindex', 'page');");
  36.         $this->addSql($insert_pagelayout "($lastId ,2 ,'pagelayout');");
  37.     }
  38.     public function down(Schema $schema): void
  39.     {
  40.         // this down() migration is auto-generated, please modify it to your needs
  41.         $this->addSql('DELETE FROM dtb_page WHERE page_name = ?',["Recommend Product"]);
  42.         $this->addSql('DELETE FROM dtb_page WHERE page_name = ?',["New Product"]);
  43.         $this->addSql('DELETE FROM dtb_page WHERE page_name = ?',["Product Review"]);
  44.         $this->addSql('DELETE FROM dtb_page WHERE page_name = ?',["Product Contact"]);
  45.     }
  46. }