migrations/Version20210715095436.php line 1

  1. <?php
  2. namespace DoctrineMigrations;
  3. use Doctrine\DBAL\Schema\Schema;
  4. use Doctrine\Migrations\AbstractMigration;
  5. /**
  6.  * Auto-generated Migration: Please modify to your needs!
  7.  */
  8. class Version20210715095436 extends AbstractMigration
  9. {
  10.     /**
  11.      * @param Schema $schema
  12.      */
  13.     public function up(Schema $schema) : void
  14.     {
  15.         // this up() migration is auto-generated, please modify it to your needs
  16.         $this->addSql('ALTER TABLE media ADD COLUMN media_flag SMALLINT DEFAULT NULL');
  17.         $this->addSql('UPDATE media SET media_flag = 1 WHERE scenario_id IS NOT NULL');
  18.         $this->addSql('INSERT INTO media (id, scenario_id, category, filename, media_order, active, is_deleted, media_name, description, users_id, preview_filename, use_prview_image, media_flag) SELECT nextval(\'seq_media_id\'), scenario_id, category, filename, media_order, active, is_deleted, CONCAT(media_name, \'_2\'), description, users_id, preview_filename, use_prview_image, 2 FROM media WHERE scenario_id IS NOT NULL AND media_flag != 2 ');
  19.     }
  20.     /**
  21.      * @param Schema $schema
  22.      */
  23.     public function down(Schema $schema) : void
  24.     {
  25.         $this->addSql('DELETE FROM media WHERE media_flag = 2');
  26.         $this->addSql('UPDATE media SET media_flag = NULL WHERE media_flag IS NOT NULL');
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.     }
  29. }