Finished migration

This commit is contained in:
Daniel Hougaard
2024-02-22 05:00:25 +01:00
parent 8333250b0b
commit 4802a36473
18 changed files with 660 additions and 369 deletions
+14 -1
View File
@@ -1,5 +1,5 @@
import { TDbClient } from "@app/db";
import { ProjectsSchema, TableName } from "@app/db/schemas";
import { ProjectsSchema, ProjectUpgradeStatus, TableName, TProjectsUpdate } from "@app/db/schemas";
import { DatabaseError } from "@app/lib/errors";
import { ormify, selectAllTableCols, sqlNestRelationships } from "@app/lib/knex";
@@ -66,6 +66,18 @@ export const projectDALFactory = (db: TDbClient) => {
}
};
const setProjectUpgradeStatus = async (projectId: string, status: ProjectUpgradeStatus) => {
try {
const data: TProjectsUpdate = {
upgradeStatus: status
} as const;
await db(TableName.Project).where({ id: projectId }).update(data);
} catch (error) {
throw new DatabaseError({ error, name: "Set project upgrade status" });
}
};
const findAllProjectsByIdentity = async (identityId: string) => {
try {
const workspaces = await db(TableName.IdentityProjectMembership)
@@ -149,6 +161,7 @@ export const projectDALFactory = (db: TDbClient) => {
return {
...projectOrm,
findAllProjects,
setProjectUpgradeStatus,
findAllProjectsByIdentity,
findProjectGhostUser,
findProjectById