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