<?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 Version20231031135036 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE authorized_actions (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, deleted TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE roles (id INT AUTO_INCREMENT NOT NULL, establishment_id INT NOT NULL, name VARCHAR(255) NOT NULL, deleted TINYINT(1) NOT NULL, INDEX IDX_B63E2EC78565851 (establishment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE roles_authorized_actions (id INT AUTO_INCREMENT NOT NULL, role_id INT NOT NULL, authorized_action_id INT NOT NULL, deleted TINYINT(1) NOT NULL, INDEX IDX_DA45BC6D60322AC (role_id), INDEX IDX_DA45BC68C4E0B33 (authorized_action_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE roles ADD CONSTRAINT FK_B63E2EC78565851 FOREIGN KEY (establishment_id) REFERENCES establishments (id)');
$this->addSql('ALTER TABLE roles_authorized_actions ADD CONSTRAINT FK_DA45BC6D60322AC FOREIGN KEY (role_id) REFERENCES roles (id)');
$this->addSql('ALTER TABLE roles_authorized_actions ADD CONSTRAINT FK_DA45BC68C4E0B33 FOREIGN KEY (authorized_action_id) REFERENCES authorized_actions (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE roles DROP FOREIGN KEY FK_B63E2EC78565851');
$this->addSql('ALTER TABLE roles_authorized_actions DROP FOREIGN KEY FK_DA45BC6D60322AC');
$this->addSql('ALTER TABLE roles_authorized_actions DROP FOREIGN KEY FK_DA45BC68C4E0B33');
$this->addSql('DROP TABLE authorized_actions');
$this->addSql('DROP TABLE roles');
$this->addSql('DROP TABLE roles_authorized_actions');
}
}