migrations/Version20231221112545.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 Version20231221112545 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // To insert cms pages//
  18.         $recordsToInsert = [
  19.             [
  20.                 'name' => 'Media Kit',
  21.                 'slug' => 'media_kit',
  22.                 'template' => 'media_kit',
  23.                 'class' => null,
  24.                 'content' => 'Media Kit'// Your content here
  25.                 'seo_title' => null,
  26.                 'seo_meta_keyword' => null,
  27.                 'seo_description' => null,
  28.                 'is_active' => 1,
  29.                 'deleted' => 1,
  30.                 'created_at' => '2023-12-21 13:16:32',
  31.                 'updated_at' => '2023-12-21 13:17:37',
  32.                 'deleted_at' => null,
  33.             ], 
  34.             [
  35.                 'name' => 'Advertise Landing',
  36.                 'slug' => 'advertise_landing',
  37.                 'template' => 'advertise_landing',
  38.                 'class' => null,
  39.                 'content' => 'Advertise Landing'// Your content here
  40.                 'seo_title' => null,
  41.                 'seo_meta_keyword' => null,
  42.                 'seo_description' => null,
  43.                 'is_active' => 1,
  44.                 'deleted' => 1,
  45.                 'created_at' => '2023-12-21 13:16:32',
  46.                 'updated_at' => '2023-12-21 13:17:37',
  47.                 'deleted_at' => null,
  48.             ], 
  49.            
  50.             
  51.         ];
  52.             foreach ($recordsToInsert as $record) {
  53.                 $slugExists $this->connection->fetchAssociative(
  54.                     'SELECT id FROM cms_pages WHERE slug = :slug',
  55.                     ['slug' => $record['slug']]
  56.                 );
  57.                 if ($slugExists === false) {
  58.                     $this->addSql('INSERT INTO cms_pages (name, slug, template, class, content, seo_title, seo_meta_keyword, seo_description, is_active, deleted, created_at, updated_at, deleted_at) VALUES (:name, :slug, :template, :class, :content, :seo_title, :seo_meta_keyword, :seo_description, :is_active, :deleted, :created_at, :updated_at, :deleted_at)'$record);
  59.                 }
  60.             }
  61.     }
  62.     public function down(Schema $schema): void
  63.     {
  64.         
  65.     }
  66. }