mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-28 13:58:31 +02:00
Implemented permission system for part parameters.
This commit is contained in:
parent
e72fc2716b
commit
f8af23b92b
6 changed files with 30 additions and 3 deletions
|
@ -23,7 +23,19 @@ final class Version20200311204104 extends AbstractMigration
|
|||
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$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');
|
||||
$this->addSql('ALTER TABLE `groups` ADD perms_parts_parameters SMALLINT NOT NULL');
|
||||
$this->addSql('ALTER TABLE `users` ADD perms_parts_parameters SMALLINT NOT NULL');
|
||||
$this->addSql('ALTER TABLE log CHANGE level level TINYINT');
|
||||
|
||||
$sql = 'UPDATE `groups`' .
|
||||
'SET perms_parts_parameters = 341 WHERE (id = 1 AND name = "admins") OR (id = 3 AND name = "users");';
|
||||
$this->addSql($sql);
|
||||
|
||||
$sql = 'UPDATE `groups`' .
|
||||
'SET perms_parts_parameters = 681 WHERE (id = 2 AND name = "readonly");';
|
||||
$this->addSql($sql);
|
||||
|
||||
$this->write('<question>[!!!] Permissions were updated! Please check if they fit your expectations!</question>');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
|
@ -32,6 +44,8 @@ final class Version20200311204104 extends AbstractMigration
|
|||
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('DROP TABLE parameters');
|
||||
$this->addSql('ALTER TABLE `groups` DROP perms_parts_parameters');
|
||||
$this->addSql('ALTER TABLE `users` DROP perms_parts_parameters');
|
||||
$this->addSql('ALTER TABLE log CHANGE level level TINYINT(1) DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue