mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-27 07:33:30 +00:00
Add ordering property on Motive.php and create migration
This commit is contained in:
@@ -51,13 +51,15 @@ class Motive
|
||||
#[ORM\ManyToOne(targetEntity: Motive::class, inversedBy: 'children')]
|
||||
private ?Motive $parent = null;
|
||||
|
||||
|
||||
/**
|
||||
* @var Collection<int, Motive>&Selectable<int, Motive>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Motive::class, mappedBy: 'parent')]
|
||||
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: Motive::class)]
|
||||
private Collection&Selectable $children;
|
||||
|
||||
#[ORM\Column(name: 'ordering', type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true, options: ['default' => '0.0'])]
|
||||
private float $ordering = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->storedObjects = new ArrayCollection();
|
||||
@@ -218,4 +220,13 @@ class Motive
|
||||
|
||||
return $collection;
|
||||
}
|
||||
public function getOrdering(): float
|
||||
{
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
public function setOrdering(float $ordering): void
|
||||
{
|
||||
$this->ordering = $ordering;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Ticket;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20251022081554 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add ordering property on motive entity';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_ticket.motive ADD ordering DOUBLE PRECISION DEFAULT \'0.0\'');
|
||||
$this->addSql('UPDATE chill_ticket.motive SET ordering = id * 100');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_ticket.motive DROP ordering');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user