fix: prevent duplicate indices when creating a new list

This commit is contained in:
Henry
2025-06-01 22:28:46 +01:00
parent 64c5488f0c
commit d602c1f960

View File

@@ -24,7 +24,7 @@ export const create = async (
orderBy: [desc(lists.index)], orderBy: [desc(lists.index)],
}); });
const index = list?.index ? list.index + 1 : 0; const index = list ? list.index + 1 : 0;
const [result] = await tx const [result] = await tx
.insert(lists) .insert(lists)
@@ -191,7 +191,7 @@ export const softDeleteAllByBoardId = async (
deletedBy: string; deletedBy: string;
}, },
) => { ) => {
const [result] = await db const result = await db
.update(lists) .update(lists)
.set({ deletedAt: args.deletedAt, deletedBy: args.deletedBy }) .set({ deletedAt: args.deletedAt, deletedBy: args.deletedBy })
.where(and(eq(lists.boardId, args.boardId), isNull(lists.deletedAt))) .where(and(eq(lists.boardId, args.boardId), isNull(lists.deletedAt)))