feat: gérer l'ordre des champs personnalisés
This commit is contained in:
@@ -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";
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user