Internal: Add ticket_rel_user entity and migration

pull/5827/head
christianbeeznst 2 months ago
parent fb067dc395
commit d601c18850
  1. 61
      src/CoreBundle/Entity/TicketRelUser.php
  2. 37
      src/CoreBundle/Migrations/Schema/V200/Version20240927002830.php

@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'ticket_rel_user')]
#[ORM\Entity]
class TicketRelUser
{
use UserTrait;
#[ORM\Id]
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected User $user;
#[ORM\Id]
#[ORM\ManyToOne(targetEntity: Ticket::class)]
#[ORM\JoinColumn(name: 'ticket_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected Ticket $ticket;
#[ORM\Column(name: 'notify', type: 'boolean', nullable: false)]
protected bool $notify;
public function __construct(User $user, Ticket $ticket, bool $notify)
{
$this->user = $user;
$this->ticket = $ticket;
$this->notify = $notify;
}
public function getTicket(): Ticket
{
return $this->ticket;
}
public function setTicket(Ticket $ticket): self
{
$this->ticket = $ticket;
return $this;
}
public function isNotify(): bool
{
return $this->notify;
}
public function setNotify(bool $notify): self
{
$this->notify = $notify;
return $this;
}
}

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
final class Version20240927002830 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Create ticket_rel_user table';
}
public function up(Schema $schema): void
{
$this->addSql("
CREATE TABLE ticket_rel_user (
user_id INT NOT NULL,
ticket_id INT NOT NULL,
notify TINYINT(1) NOT NULL,
PRIMARY KEY(user_id, ticket_id),
CONSTRAINT FK_ticket_rel_user_user_id FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE,
CONSTRAINT FK_ticket_rel_user_ticket_id FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id) ON DELETE CASCADE
)
");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE ticket_rel_user");
}
}
Loading…
Cancel
Save