migrations/Version20221110072816.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 Version20221110072816 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql('ALTER TABLE position ADD on_trainer_page BOOLEAN NULL');
  18.         $this->addSql('UPDATE position SET on_trainer_page = TRUE');
  19.         $this->addSql('ALTER TABLE position ALTER COLUMN on_trainer_page SET NOT NULL');
  20.         $this->addSql('COMMENT ON COLUMN position.on_trainer_page IS \'Отображать ли при выборе тренеров\'');
  21.         $this->addSql('ALTER TABLE position ADD on_director_page BOOLEAN NULL');
  22.         $this->addSql('UPDATE position SET on_director_page = FALSE');
  23.         $this->addSql('ALTER TABLE position ALTER COLUMN on_director_page SET NOT NULL');
  24.         $this->addSql('COMMENT ON COLUMN position.on_director_page IS \'Отображать ли при выборе директоров\'');
  25.     }
  26.     public function postUp(Schema $schema): void
  27.     {
  28.         $userId $this->connection->fetchOne('SELECT id FROM "user" LIMIT 1');
  29.         $this->connection->insert('position', [
  30.             'name' => 'Начальник отдела',
  31.             'on_trainer_page' => 0,
  32.             'on_director_page' => 1,
  33.             'created_by_id' => $userId
  34.         ]);
  35.         $this->connection->insert('position', [
  36.             'name' => 'Помощник министра',
  37.             'on_trainer_page' => 0,
  38.             'on_director_page' => 1,
  39.             'created_by_id' => $userId
  40.         ]);
  41.     }
  42.     public function down(Schema $schema): void
  43.     {
  44.         // this down() migration is auto-generated, please modify it to your needs
  45.         $this->addSql('ALTER TABLE position DROP on_trainer_page');
  46.         $this->addSql('ALTER TABLE position DROP on_director_page');
  47.     }
  48. }