File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-console */
2
+ import { readFile } from 'node:fs/promises' ;
3
+ import { BaseMigration } from '~/core/database' ;
4
+
5
+ interface ExternalDepartmentId {
6
+ departmentId : string ;
7
+ name ?: string ;
8
+ }
9
+
10
+ export class CreateUsedDeptIdListMigration extends BaseMigration {
11
+ async up ( ) {
12
+ const filePath = new URL (
13
+ '../../../../../All-Department-Ids-From-Intaact.csv' ,
14
+ import . meta. url ,
15
+ ) ;
16
+ const fileContent = await readFile ( filePath , 'utf-8' ) ;
17
+ const rows = fileContent . trim ( ) . split ( / \r ? \n / ) . slice ( 1 ) ; // Skip header
18
+ const _idList : ExternalDepartmentId [ ] = rows . flatMap ( ( row ) => {
19
+ const [ departmentId , name ] = row . split ( ',' ) ;
20
+ if ( departmentId ) {
21
+ return { departmentId, name } ;
22
+ }
23
+ return [ ] ;
24
+ } ) ;
25
+ }
26
+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { ProjectEngagementConnectionResolver } from './engagement-connection.res
14
14
import { FinancialApproverModule } from './financial-approver/financial-approver.module' ;
15
15
import * as handlers from './handlers' ;
16
16
import { InternshipProjectResolver } from './internship-project.resolver' ;
17
+ import { CreateUsedDeptIdListMigration } from './migrations/create-used-dept-id-list.migration' ;
17
18
import { FixDeptIdLabelMigration } from './migrations/fix-dept-id-label.migration' ;
18
19
import { RenameTranslationToMomentumMigration } from './migrations/rename-translation-to-momentum.migration' ;
19
20
import { ProjectEngagementIdResolvers } from './project-engagement-id.resolver' ;
@@ -55,6 +56,7 @@ import { ProjectWorkflowModule } from './workflow/project-workflow.module';
55
56
...Object . values ( ConcreteRepos ) ,
56
57
ProjectLoader ,
57
58
...Object . values ( handlers ) ,
59
+ CreateUsedDeptIdListMigration ,
58
60
RenameTranslationToMomentumMigration ,
59
61
FixDeptIdLabelMigration ,
60
62
] ,
You can’t perform that action at this time.
0 commit comments