<?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 Version20180829175053 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('
ALTER TABLE user
ADD timezone VARCHAR(255) DEFAULT NULL,
ADD date_format VARCHAR(255) DEFAULT NULL,
ADD allow_system_admin TINYINT(1) NOT NULL
');
$this->addSql('UPDATE user SET timezone = \'America/Los_Angeles\'');
$this->addSql('UPDATE user SET date_format = \'m/d/Y\'');
// mark all `Administrators` with system-admin permission
$this->addSql('UPDATE user SET allow_system_admin = 1 WHERE id = 9999 OR id IN (SELECT user_id FROM user_join_group WHERE group_id = 1)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('
ALTER TABLE user
DROP timezone,
DROP date_format,
DROP allow_system_admin
');
}
}