1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DoctrineMigrations; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Schema\Schema; |
8
|
|
|
use Doctrine\Migrations\AbstractMigration; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Auto-generated Migration: Please modify to your needs! |
12
|
|
|
*/ |
13
|
|
|
final class Version20200311204104 extends AbstractMigration |
14
|
|
|
{ |
15
|
|
|
public function getDescription(): string |
16
|
|
|
{ |
17
|
|
|
return ''; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function up(Schema $schema): void |
21
|
|
|
{ |
22
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
23
|
|
|
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); |
24
|
|
|
|
25
|
|
|
$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'); |
26
|
|
|
$this->addSql('ALTER TABLE `groups` ADD perms_parts_parameters SMALLINT NOT NULL'); |
27
|
|
|
$this->addSql('ALTER TABLE `users` ADD perms_parts_parameters SMALLINT NOT NULL'); |
28
|
|
|
$this->addSql('ALTER TABLE log CHANGE level level TINYINT'); |
29
|
|
|
|
30
|
|
|
$sql = 'UPDATE `groups`' . |
31
|
|
|
'SET perms_parts_parameters = 341 WHERE (id = 1 AND name = "admins") OR (id = 3 AND name = "users");'; |
32
|
|
|
$this->addSql($sql); |
33
|
|
|
|
34
|
|
|
$sql = 'UPDATE `groups`' . |
35
|
|
|
'SET perms_parts_parameters = 681 WHERE (id = 2 AND name = "readonly");'; |
36
|
|
|
$this->addSql($sql); |
37
|
|
|
|
38
|
|
|
$this->write('<question>[!!!] Permissions were updated! Please check if they fit your expectations!</question>'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function down(Schema $schema): void |
42
|
|
|
{ |
43
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
44
|
|
|
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); |
45
|
|
|
|
46
|
|
|
$this->addSql('DROP TABLE parameters'); |
47
|
|
|
$this->addSql('ALTER TABLE `groups` DROP perms_parts_parameters'); |
48
|
|
|
$this->addSql('ALTER TABLE `users` DROP perms_parts_parameters'); |
49
|
|
|
$this->addSql('ALTER TABLE log CHANGE level level TINYINT(1) DEFAULT NULL'); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|