-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Project groups are not deleted from the DB after deleting the pr…
…oject they corresponds to gf-504 (#559) * fix: add migration which adds trigger to detele unused project groups gf-504 * fix: add deletion of existed unused project groups and rename migration gf-555 * refactor: move unused project group deletion control to service gf-555
- Loading branch information
Showing
5 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
apps/backend/src/db/migrations/20240927085349_remove_unused_project_groups.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { type Knex } from "knex"; | ||
|
||
const PROJECT_GROUPS_TABLE_NAME = "project_groups"; | ||
const PROJECTS_TO_PROJECT_GROUPS_TABLE_NAME = "projects_to_project_groups"; | ||
|
||
const ColumnName = { | ||
ID: "id", | ||
PROJECT_GROUP_ID: "project_group_id", | ||
} as const; | ||
|
||
function up(knex: Knex): Promise<void> { | ||
return knex(PROJECT_GROUPS_TABLE_NAME) | ||
.whereNotIn( | ||
ColumnName.ID, | ||
knex(PROJECTS_TO_PROJECT_GROUPS_TABLE_NAME).select( | ||
ColumnName.PROJECT_GROUP_ID, | ||
), | ||
) | ||
.delete(); | ||
} | ||
|
||
function down(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
export { down, up }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters