|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace DoctrineMigrations; |
|
6
|
|
|
|
|
7
|
|
|
use App\Migrations\AbstractMultiPlatformMigration; |
|
8
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
9
|
|
|
use Doctrine\Migrations\AbstractMigration; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
13
|
|
|
*/ |
|
14
|
|
|
final class Version20200311204104 extends AbstractMultiPlatformMigration |
|
15
|
|
|
{ |
|
16
|
|
|
public function getDescription(): string |
|
17
|
|
|
{ |
|
18
|
|
|
return ''; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function mySQLUp(Schema $schema): void |
|
22
|
|
|
{ |
|
23
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
|
24
|
|
|
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.'); |
|
25
|
|
|
|
|
26
|
|
|
$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'); |
|
27
|
|
|
$this->addSql('ALTER TABLE `groups` ADD perms_parts_parameters SMALLINT NOT NULL'); |
|
28
|
|
|
$this->addSql('ALTER TABLE `users` ADD perms_parts_parameters SMALLINT NOT NULL'); |
|
29
|
|
|
$this->addSql('ALTER TABLE log CHANGE level level TINYINT'); |
|
30
|
|
|
|
|
31
|
|
|
$sql = 'UPDATE `groups`'. |
|
32
|
|
|
'SET perms_parts_parameters = 341 WHERE (id = 1 AND name = "admins") OR (id = 3 AND name = "users");'; |
|
33
|
|
|
$this->addSql($sql); |
|
34
|
|
|
|
|
35
|
|
|
$sql = 'UPDATE `groups`'. |
|
36
|
|
|
'SET perms_parts_parameters = 681 WHERE (id = 2 AND name = "readonly");'; |
|
37
|
|
|
$this->addSql($sql); |
|
38
|
|
|
|
|
39
|
|
|
$this->printPermissionUpdateMessage(); |
|
40
|
|
|
} |
|
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
|
|
|
|
|
47
|
|
|
$this->addSql('DROP TABLE parameters'); |
|
48
|
|
|
$this->addSql('ALTER TABLE `groups` DROP perms_parts_parameters'); |
|
49
|
|
|
$this->addSql('ALTER TABLE `users` DROP perms_parts_parameters'); |
|
50
|
|
|
$this->addSql('ALTER TABLE log CHANGE level level TINYINT(1) DEFAULT NULL'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function sqLiteUp(Schema $schema): void |
|
54
|
|
|
{ |
|
55
|
|
|
$this->skipIf(true, "Migration not needed for SQLite. Skipping..."); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function sqLiteDown(Schema $schema): void |
|
59
|
|
|
{ |
|
60
|
|
|
$this->skipIf(true, "Migration not needed for SQLite. Skipping..."); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|