<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221110072816 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE position ADD on_trainer_page BOOLEAN NULL');
$this->addSql('UPDATE position SET on_trainer_page = TRUE');
$this->addSql('ALTER TABLE position ALTER COLUMN on_trainer_page SET NOT NULL');
$this->addSql('COMMENT ON COLUMN position.on_trainer_page IS \'Отображать ли при выборе тренеров\'');
$this->addSql('ALTER TABLE position ADD on_director_page BOOLEAN NULL');
$this->addSql('UPDATE position SET on_director_page = FALSE');
$this->addSql('ALTER TABLE position ALTER COLUMN on_director_page SET NOT NULL');
$this->addSql('COMMENT ON COLUMN position.on_director_page IS \'Отображать ли при выборе директоров\'');
}
public function postUp(Schema $schema): void
{
$userId = $this->connection->fetchOne('SELECT id FROM "user" LIMIT 1');
$this->connection->insert('position', [
'name' => 'Начальник отдела',
'on_trainer_page' => 0,
'on_director_page' => 1,
'created_by_id' => $userId
]);
$this->connection->insert('position', [
'name' => 'Помощник министра',
'on_trainer_page' => 0,
'on_director_page' => 1,
'created_by_id' => $userId
]);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE position DROP on_trainer_page');
$this->addSql('ALTER TABLE position DROP on_director_page');
}
}