migrations/Version20231211051925.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 Version20231211051925 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' => 'About Us',
  21.                 'slug' => 'about_us',
  22.                 'template' => 'about_us',
  23.                 'class' => null,
  24.                 'content' => 'About Us'// 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-11 13:16:32',
  31.                 'updated_at' => '2023-12-11 13:17:37',
  32.                 'deleted_at' => null,
  33.             ], 
  34.             
  35.         ];
  36.             foreach ($recordsToInsert as $record) {
  37.                 $slugExists $this->connection->fetchAssociative(
  38.                     'SELECT id FROM cms_pages WHERE slug = :slug',
  39.                     ['slug' => $record['slug']]
  40.                 );
  41.                 if ($slugExists === false) {
  42.                     $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);
  43.                 }
  44.             }
  45.     }
  46.     public function down(Schema $schema): void
  47.     {
  48.         
  49.     }
  50. }