migrations/Version20200311204104.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\Migration\AbstractMultiPlatformMigration;
  5. use Doctrine\DBAL\Schema\Schema;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20200311204104 extends AbstractMultiPlatformMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function mySQLUp(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE parameters (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, symbol VARCHAR(255) NOT NULL, value_min DOUBLE PRECISION DEFAULT NULL, value_typical DOUBLE PRECISION DEFAULT NULL, value_max DOUBLE PRECISION DEFAULT NULL, unit VARCHAR(255) NOT NULL, value_text VARCHAR(255) NOT NULL, param_group VARCHAR(255) NOT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, type SMALLINT NOT NULL, element_id INT NOT NULL, INDEX IDX_69348FE1F1F2A24 (element_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE `groups` ADD perms_parts_parameters SMALLINT NOT NULL');
  21.         $this->addSql('ALTER TABLE `users` ADD perms_parts_parameters SMALLINT NOT NULL');
  22.         $this->addSql('ALTER TABLE log CHANGE level level TINYINT');
  23.         $sql 'UPDATE `groups`'.
  24.             'SET perms_parts_parameters = 341 WHERE (id = 1 AND name = "admins") OR (id = 3 AND name = "users");';
  25.         $this->addSql($sql);
  26.         $sql 'UPDATE `groups`'.
  27.             'SET perms_parts_parameters = 681 WHERE (id = 2 AND name = "readonly");';
  28.         $this->addSql($sql);
  29.         $this->printPermissionUpdateMessage();
  30.     }
  31.     public function mySQLDown(Schema $schema): void
  32.     {
  33.         // this down() migration is auto-generated, please modify it to your needs
  34.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  35.         $this->addSql('DROP TABLE parameters');
  36.         $this->addSql('ALTER TABLE `groups` DROP perms_parts_parameters');
  37.         $this->addSql('ALTER TABLE `users` DROP perms_parts_parameters');
  38.         $this->addSql('ALTER TABLE log CHANGE level level TINYINT(1) DEFAULT NULL');
  39.     }
  40.     public function sqLiteUp(Schema $schema): void
  41.     {
  42.         $this->warnIf(true"Migration not needed for SQLite. Skipping...");
  43.     }
  44.     public function sqLiteDown(Schema $schema): void
  45.     {
  46.         $this->warnIf(true"Migration not needed for SQLite. Skipping...");
  47.     }
  48. }