<?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 Version20231221112932 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
// To insert cms pages sections//
$cms_pages = $this->connection->fetchAssociative(
'SELECT id FROM cms_pages WHERE slug = :slug',
['slug' => 'advertise_landing']
);
$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],
['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],
['cms_id_id' => $cms_pages['id'], 'section_name' => 'Section 3', 'section_slug' => 'section_3', 'backend_template' => 'section_3', 'frontend_template' => 'section_3', 'position' => '3','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
{
}
}