migrations/Version20191214153125.php line 1

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
  4.  *
  5.  * Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU Affero General Public License as published
  9.  * by the Free Software Foundation, either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU Affero General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Affero General Public License
  18.  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  19.  */
  20. declare(strict_types=1);
  21. namespace DoctrineMigrations;
  22. use App\Migration\AbstractMultiPlatformMigration;
  23. use Doctrine\DBAL\Schema\Schema;
  24. /**
  25.  * Auto-generated Migration: Please modify to your needs!
  26.  */
  27. final class Version20191214153125 extends AbstractMultiPlatformMigration
  28. {
  29.     public function getDescription(): string
  30.     {
  31.         return '';
  32.     }
  33.     public function mySQLUp(Schema $schema): void
  34.     {
  35.         // this up() migration is auto-generated, please modify it to your needs
  36.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  37.         $this->addSql('CREATE TABLE u2f_keys (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, key_handle VARCHAR(64) NOT NULL, public_key VARCHAR(255) NOT NULL, certificate LONGTEXT NOT NULL, counter VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_4F4ADB4BA76ED395 (user_id), UNIQUE INDEX user_unique (user_id, key_handle), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  38.         $this->addSql('ALTER TABLE u2f_keys ADD CONSTRAINT FK_4F4ADB4BA76ED395 FOREIGN KEY (user_id) REFERENCES `users` (id)');
  39.         $this->addSql('ALTER TABLE `groups` ADD enforce_2fa TINYINT(1) NOT NULL');
  40.         $this->addSql('ALTER TABLE users ADD google_authenticator_secret VARCHAR(255) DEFAULT NULL, ADD backup_codes LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', ADD backup_codes_generation_date DATETIME DEFAULT NULL, ADD trusted_device_cookie_version INT NOT NULL');
  41.     }
  42.     public function mySQLDown(Schema $schema): void
  43.     {
  44.         // this down() migration is auto-generated, please modify it to your needs
  45.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  46.         $this->addSql('DROP TABLE u2f_keys');
  47.         $this->addSql('ALTER TABLE `groups` DROP enforce_2fa');
  48.         $this->addSql('ALTER TABLE `users` DROP google_authenticator_secret, DROP backup_codes, DROP backup_codes_generation_date, DROP trusted_device_cookie_version');
  49.     }
  50.     public function sqLiteUp(Schema $schema): void
  51.     {
  52.         $this->warnIf(true"Migration not needed for SQLite. Skipping...");
  53.     }
  54.     public function sqLiteDown(Schema $schema): void
  55.     {
  56.         $this->warnIf(true"Migration not needed for SQLite. Skipping...");
  57.     }
  58. }