update UO entity to handle roles

This commit is contained in:
Charles 2026-02-10 16:01:43 +01:00
parent 6a147cf6dd
commit a9493bfb0f
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?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 Version20260210131727 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('ALTER TABLE users_organizations ADD role_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE users_organizations ADD CONSTRAINT FK_4B991472D60322AC FOREIGN KEY (role_id) REFERENCES roles (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_4B991472D60322AC ON users_organizations (role_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE users_organizations DROP CONSTRAINT FK_4B991472D60322AC');
$this->addSql('DROP INDEX IDX_4B991472D60322AC');
$this->addSql('ALTER TABLE users_organizations DROP role_id');
}
}

View File

@ -41,6 +41,9 @@ class UsersOrganizations
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $modifiedAt = null; private ?\DateTimeImmutable $modifiedAt = null;
#[ORM\ManyToOne]
private ?Roles $role = null;
public function __construct() public function __construct()
{ {
$this->isActive = true; // Default value for isActive $this->isActive = true; // Default value for isActive
@ -147,4 +150,16 @@ class UsersOrganizations
return $this; return $this;
} }
public function getRole(): ?Roles
{
return $this->role;
}
public function setRole(?Roles $role): static
{
$this->role = $role;
return $this;
}
} }