mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 21:27:10 +00:00
Add transaction support
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { Knex } from "knex";
|
||||||
|
|
||||||
import { TDbClient } from "@app/db";
|
import { TDbClient } from "@app/db";
|
||||||
import { ProjectsSchema, ProjectUpgradeStatus, TableName, TProjectsUpdate } from "@app/db/schemas";
|
import { ProjectsSchema, ProjectUpgradeStatus, TableName, TProjectsUpdate } from "@app/db/schemas";
|
||||||
import { DatabaseError } from "@app/lib/errors";
|
import { DatabaseError } from "@app/lib/errors";
|
||||||
@@ -66,13 +68,13 @@ export const projectDALFactory = (db: TDbClient) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setProjectUpgradeStatus = async (projectId: string, status: ProjectUpgradeStatus) => {
|
const setProjectUpgradeStatus = async (projectId: string, status: ProjectUpgradeStatus | null, tx?: Knex) => {
|
||||||
try {
|
try {
|
||||||
const data: TProjectsUpdate = {
|
const data: TProjectsUpdate = {
|
||||||
upgradeStatus: status
|
upgradeStatus: status
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
await db(TableName.Project).where({ id: projectId }).update(data);
|
await (tx || db)(TableName.Project).where({ id: projectId }).update(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new DatabaseError({ error, name: "Set project upgrade status" });
|
throw new DatabaseError({ error, name: "Set project upgrade status" });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user