feat(normalization) : drop structure and productIds JSON columns

- Remove Composant.structure property, getter/setter
- Remove Piece.productIds property, setProductIds()
- Update fixtures to remove dropped columns
- Add migrations to drop both columns

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-13 08:19:54 +01:00
parent 8ed5f90b63
commit a6139d7090
8 changed files with 179 additions and 173 deletions

View File

@@ -79,10 +79,6 @@ class Piece
#[Groups(['piece:read'])]
private ?Product $product = null;
#[ORM\Column(type: Types::JSON, nullable: true, name: 'productIds')]
#[Groups(['piece:read'])]
private ?array $productIds = null;
/**
* @var Collection<int, Constructeur>
*/
@@ -214,15 +210,6 @@ class Piece
if (null !== $product) {
$this->addProduct($product);
if (empty($this->productIds)) {
$productId = $product->getId();
$this->productIds = $productId ? [$productId] : null;
}
}
if (!$product && empty($this->productIds)) {
$this->productIds = null;
}
return $this;
@@ -231,36 +218,12 @@ class Piece
/**
* @return string[]
*/
#[Groups(['piece:read'])]
public function getProductIds(): array
{
return $this->products->map(fn (Product $p) => $p->getId())->toArray();
}
public function setProductIds(?array $productIds): static
{
if (!is_array($productIds)) {
$this->productIds = null;
return $this;
}
$normalized = array_values(
array_unique(
array_filter(
array_map(
static fn ($value) => is_string($value) ? trim($value) : '',
$productIds,
),
static fn (string $value) => '' !== $value,
),
),
);
$this->productIds = [] === $normalized ? null : $normalized;
return $this;
}
/**
* @return Collection<int, Constructeur>
*/