migrations/Version20240130072212.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 Version20240130072212 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         
  18.             // this up() migration is auto-generated, please modify it to your needs
  19.             $recordsToInsert = [
  20.                 
  21.                 [
  22.                     'name' => 'Home',
  23.                     'slug' => 'home',
  24.                     'template' => 'home',
  25.                     'class' => null,
  26.                     'content' => 'Home'// Your content here
  27.                     'seo_title' => null,
  28.                     'seo_meta_keyword' => null,
  29.                     'seo_description' => null,
  30.                     'is_active' => 1,
  31.                     'deleted' => 1,
  32.                     'created_at' => '2023-11-30 13:16:32',
  33.                     'updated_at' => '2023-11-30 13:17:37',
  34.                     'deleted_at' => null,
  35.                 ],     
  36.                                
  37.                 
  38.             ];
  39.             foreach ($recordsToInsert as $record) {
  40.                 $slugExists $this->connection->fetchAssociative(
  41.                     'SELECT id FROM cms_pages WHERE slug = :slug',
  42.                     ['slug' => $record['slug']]
  43.                 );
  44.         
  45.                 
  46.                 if ($slugExists === false) {
  47.                     $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);
  48.                 }
  49.             }
  50.         }
  51.     
  52.     public function down(Schema $schema): void
  53.     {
  54.         
  55.     }
  56. }