fix: project environment positions

This commit is contained in:
Daniel Hougaard
2024-10-07 12:52:59 +04:00
parent f50b0876e4
commit 33b54e78f9
5 changed files with 33 additions and 4 deletions
@@ -65,10 +65,16 @@ export const projectEnvDALFactory = (db: TDbClient) => {
}
};
const shiftPositions = async (projectId: string, pos: number, tx?: Knex) => {
// Shift all positions >= the new position up by 1
await (tx || db)(TableName.Environment).where({ projectId }).where("position", ">=", pos).increment("position", 1);
};
return {
...projectEnvOrm,
findBySlugs,
findLastEnvPosition,
updateAllPosition
updateAllPosition,
shiftPositions
};
};