<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240222083155 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE rights (id INT AUTO_INCREMENT NOT NULL, module_name VARCHAR(255) DEFAULT NULL, label VARCHAR(255) DEFAULT NULL, rights_code VARCHAR(255) DEFAULT NULL, is_active TINYINT(1) NOT NULL, lvl INT DEFAULT NULL, position_module INT DEFAULT NULL, position INT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE users_rights (user_id INT NOT NULL, rights_id INT NOT NULL, INDEX IDX_E875F93A76ED395 (user_id), INDEX IDX_E875F93B196EE6E (rights_id), PRIMARY KEY(user_id, rights_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE users_rights ADD CONSTRAINT FK_E875F93A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE users_rights ADD CONSTRAINT FK_E875F93B196EE6E FOREIGN KEY (rights_id) REFERENCES rights (id) ON DELETE CASCADE');
$this->addSql('INSERT INTO rights (module_name, label, rights_code, is_active, lvl, position_module, position) VALUES
("sidebar.menu.collab", "rights.menu.collab.access", "COLLAB_ACCESS", 1, 0, 1, 1),
("sidebar.menu.expense", "rights.menu.expense.access", "EXPENSE_ACCESS", 1, 0, 2, 1),
("sidebar.menu.planning", "rights.menu.planning.access", "PLANNING_ACCESS", 1, 0, 3, 1),
("sidebar.menu.absence", "rights.menu.absence.access", "ABSENCE_ACCESS", 1, 0, 4, 1),
("sidebar.menu.score_section", "rights.menu.score_section.access", "SCORE_ACCESS", 1, 0, 5, 1),
("sidebar.menu.client", "rights.menu.client.access", "CLIENT_ACCESS", 1, 0, 6, 1),
("sidebar.menu.opportunity_global", "rights.menu.opportunity_global.access", "CRM_ACCESS", 1, 0, 7, 1),
("sidebar.menu.product", "rights.menu.product.access", "CATALOG_ACCESS", 1, 0, 8, 1),
("sidebar.menu.invoicing", "rights.menu.invoicing.access", "INVOICING_ACCESS", 1, 0, 9, 1),
("sidebar.menu.inventory", "rights.menu.inventory.access", "INVENTORY_ACCESS", 1, 0, 10, 1),
("sidebar.menu.cashflow", "rights.menu.cashflow.access", "CASHFLOW_ACCESS", 1, 0, 11, 1),
("sidebar.menu.project_global", "rights.menu.project_global.access", "PROJECT_ACCESS", 1, 0, 12, 2),
("sidebar.menu.supplier_node", "rights.menu.supplier.access", "SUPPLIERS_ACCESS", 1, 0, 13, 1)
');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE users_rights DROP FOREIGN KEY FK_E875F93B196EE6E');
$this->addSql('DROP TABLE rights');
$this->addSql('DROP TABLE users_rights');
}
}