migrations/Version20180829175053.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 Version20180829175053 extends AbstractMigration
  10. {
  11.     public function up(Schema $schema): void
  12.     {
  13.         // this up() migration is auto-generated, please modify it to your needs
  14.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  15.         $this->addSql('
  16.             ALTER TABLE user
  17.                 ADD timezone VARCHAR(255) DEFAULT NULL,
  18.                 ADD date_format VARCHAR(255) DEFAULT NULL,
  19.                 ADD allow_system_admin TINYINT(1) NOT NULL
  20.         ');
  21.         $this->addSql('UPDATE user SET timezone = \'America/Los_Angeles\'');
  22.         $this->addSql('UPDATE user SET date_format = \'m/d/Y\'');
  23.         // mark all `Administrators` with system-admin permission
  24.         $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)');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  30.         $this->addSql('
  31.             ALTER TABLE user
  32.                 DROP timezone,
  33.                 DROP date_format,
  34.                 DROP allow_system_admin
  35.         ');
  36.     }
  37. }