migrations/Version20240111041350.php line 1

Open in your IDE?
  1. <?php
    
    declare(strict_types=1);
    
    namespace DoctrineMigrations;
    
    use Doctrine\DBAL\Schema\Schema;
    use Doctrine\Migrations\AbstractMigration;
    
    /**
     * Auto-generated Migration: Please modify to your needs!
     */
    final class Version20240111041350 extends AbstractMigration
    {
        public function getDescription(): string
        {
            return '';
        }
    
        public function up(Schema $schema): void
        {
            $cms_pages = $this->connection->fetchAssociative(
                'SELECT id FROM cms_pages WHERE slug = :slug',
                ['slug' => 'architect-registration']
            );
            $entries = [
                ['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],
               
                
                
            ];
            foreach ($entries as $entry) {
                $existingEntry = $this->connection->fetchAssociative(
                    'SELECT * FROM cms_sections WHERE cms_id_id = :cms_id_id AND section_name = :section_name',
                    ['cms_id_id' => $cms_pages['id'], 'section_name' => $entry['section_name']]
                );
                if (!$existingEntry) {
                    $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)', [
                        'cms_id_id' => $entry['cms_id_id'],
                        'section_name' => $entry['section_name'],
                        'section_slug' => $entry['section_slug'],
                        'backend_template' => $entry['backend_template'],
                        'frontend_template' => $entry['frontend_template'],
                        'position' => $entry['position'],
                        'deleted_at' => $entry['deleted_at'],
                    ]);
                }
            }
        }
        public function down(Schema $schema): void
        {
          
        }
    }