migrations/Version20240130223343.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 Version20240130223343 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $cms_pages $this->connection->fetchAssociative(
  18.             'SELECT id FROM cms_pages WHERE slug = :slug',
  19.             ['slug' => 'home']
  20.         );
  21.         $entries = [
  22.             ['cms_id_id' => $cms_pages['id'], 'section_name' => 'Section 1''section_slug' => 'section_1''backend_template' => 'section_1''frontend_template' => 'section_1''position' => '1','deleted_at'=>null],
  23.             ['cms_id_id' => $cms_pages['id'], 'section_name' => 'Section 2''section_slug' => 'section_2''backend_template' => 'section_2''frontend_template' => 'section_2''position' => '2','deleted_at'=>null],
  24.             ['cms_id_id' => $cms_pages['id'], 'section_name' => 'Section 4''section_slug' => 'section_4''backend_template' => 'section_4''frontend_template' => 'section_4''position' => '4','deleted_at'=>null],
  25.             ['cms_id_id' => $cms_pages['id'], 'section_name' => 'Section 5''section_slug' => 'section_5''backend_template' => 'section_5''frontend_template' => 'section_5''position' => '5','deleted_at'=>null],
  26.             ['cms_id_id' => $cms_pages['id'], 'section_name' => 'Section 6''section_slug' => 'section_6''backend_template' => 'section_6''frontend_template' => 'section_6''position' => '6','deleted_at'=>null],
  27.             
  28.             
  29.         ];
  30.         foreach ($entries as $entry) {
  31.             $existingEntry $this->connection->fetchAssociative(
  32.                 'SELECT * FROM cms_sections WHERE cms_id_id = :cms_id_id AND section_name = :section_name',
  33.                 ['cms_id_id' => $cms_pages['id'], 'section_name' => $entry['section_name']]
  34.             );
  35.             if (!$existingEntry) {
  36.                 $this->addSql('INSERT INTO cms_sections (cms_id_id, section_name , section_slug,backend_template,frontend_template,position,deleted_at) VALUES (:cms_id_id, :section_name, :section_slug, :backend_template,:frontend_template,:position,deleted_at)', [
  37.                     'cms_id_id' => $entry['cms_id_id'],
  38.                     'section_name' => $entry['section_name'],
  39.                     'section_slug' => $entry['section_slug'],
  40.                     'backend_template' => $entry['backend_template'],
  41.                     'frontend_template' => $entry['frontend_template'],
  42.                     'position' => $entry['position'],
  43.                     'deleted_at' => $entry['deleted_at'],
  44.                 ]);
  45.             }
  46.         }
  47.     }
  48.     public function down(Schema $schema): void
  49.     {
  50.         
  51.         
  52.     }
  53. }