From 2dfa501a652a37527ec850bfe2cc1f0efc48b751 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Mon, 2 Mar 2026 16:33:22 +0100 Subject: [PATCH] fix(sites) : add PATCH operation and fix migration constraint drop Add Patch operation to Site entity (was only Put, causing 405 errors). Fix migration to use ALTER TABLE DROP CONSTRAINT instead of DROP INDEX for the piece name unique constraint. Co-Authored-By: Claude Opus 4.6 --- migrations/Version20260302103003.php | 4 ++-- src/Entity/Site.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/migrations/Version20260302103003.php b/migrations/Version20260302103003.php index 09cb327..51a5819 100644 --- a/migrations/Version20260302103003.php +++ b/migrations/Version20260302103003.php @@ -23,8 +23,8 @@ final class Version20260302103003 extends AbstractMigration $this->addSql('COMMENT ON COLUMN comments.created_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('COMMENT ON COLUMN comments.updated_at IS \'(DC2Type:datetime_immutable)\''); - // Piece: remove unique on name - $this->addSql('DROP INDEX IF EXISTS uniq_b92d74725e237e06'); + // Piece: remove unique constraint on name (it's a constraint, not just an index) + $this->addSql('ALTER TABLE pieces DROP CONSTRAINT IF EXISTS uniq_b92d74725e237e06'); // Deduplicate piece references before adding unique constraint $this->addSql(" diff --git a/src/Entity/Site.php b/src/Entity/Site.php index 6eb4ae8..816d55c 100644 --- a/src/Entity/Site.php +++ b/src/Entity/Site.php @@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Delete; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Put; use App\Repository\SiteRepository; @@ -28,6 +29,7 @@ use Symfony\Component\Validator\Constraints as Assert; new GetCollection(security: "is_granted('ROLE_VIEWER')"), new Post(security: "is_granted('ROLE_GESTIONNAIRE')"), new Put(security: "is_granted('ROLE_GESTIONNAIRE')"), + new Patch(security: "is_granted('ROLE_GESTIONNAIRE')"), new Delete(security: "is_granted('ROLE_GESTIONNAIRE')"), ], paginationClientItemsPerPage: true,