feat: gérer l'ordre des champs personnalisés

This commit is contained in:
Matthieu
2025-10-28 18:08:08 +01:00
parent 635ea0e84e
commit 9f522a6dbb
15 changed files with 134 additions and 27 deletions

View File

@@ -0,0 +1,18 @@
-- Introduce an order index for custom fields so their ordering can be persisted.
ALTER TABLE "custom_fields"
ADD COLUMN "orderIndex" INTEGER NOT NULL DEFAULT 0;
WITH ranked AS (
SELECT
"id",
ROW_NUMBER() OVER (
PARTITION BY "typeMachineId", "typeComposantId", "typePieceId"
ORDER BY "createdAt", "id"
) - 1 AS rn
FROM "custom_fields"
)
UPDATE "custom_fields"
SET "orderIndex" = ranked.rn
FROM ranked
WHERE ranked."id" = "custom_fields"."id";

View File

@@ -245,6 +245,7 @@ model CustomField {
required Boolean @default(false)
defaultValue String?
options String[] // Pour les champs de type SELECT
orderIndex Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt