1- require ( 'dotenv' ) . config ( ) ;
2- const path = require ( 'path' ) ;
3- const fs = require ( 'fs' ) ;
1+ require ( 'dotenv' ) . config ( )
2+ const path = require ( 'path' )
3+ const fs = require ( 'fs' )
44
55// === MIGRATOR IMPORTS ===
66// Import migration functions for each data type
77// The 'Auto' versions dynamically choose between batch and simple migration
88// based on the size of the input file (optimized for large datasets)
9- const { migrateMemberProfilesAuto } = require ( './migrators/migrateMemberProfileAuto' ) ; // Large dataset
10- const { migrateMemberStatsAuto } = require ( './migrators/migrateMemberStatsAuto' ) ; // Large dataset
11- const { migrateResourceRoles } = require ( './migrators/migrateResourceRole' ) ;
12- const { migrateResourceRolePhaseDependencies } = require ( './migrators/migrateResourceRolePhaseDependency' ) ;
13- const { migrateResourceAuto } = require ( './migrators/migrateResourceAuto' ) ; // Large dataset (line-based JSON from ElasticSearch)
9+ const { migrateMemberProfilesAuto } = require ( './migrators/migrateMemberProfileAuto' ) // Large dataset
10+ const { migrateMemberStatsAuto } = require ( './migrators/migrateMemberStatsAuto' ) // Large dataset
11+ const { migrateResourceRoles } = require ( './migrators/migrateResourceRole' )
12+ const { migrateResourceRolePhaseDependencies } = require ( './migrators/migrateResourceRolePhaseDependency' )
13+ const { migrateResourceAuto } = require ( './migrators/migrateResourceAuto' ) // Large dataset (line-based JSON from ElasticSearch)
1414
1515// === MIGRATION STEPS ===
1616// Map each step name to its corresponding function.
1717// Each function logs execution time and calls its migrator.
1818const steps = {
19- // 'member-profiles': async (filePath) => {
20- // const start = Date.now();
21- // await migrateMemberProfilesAuto(filePath);
22- // console.log(`⏱️ Duration: ${((Date.now() - start) / 1000).toFixed(2)}s.`);
23- // },
24- // 'member-stats': async (filePath) => {
25- // const start = Date.now();
26- // await migrateMemberStatsAuto(filePath);
27- // console.log(`⏱️ Duration: ${((Date.now() - start) / 1000).toFixed(2)}s.`);
28- // },
29- // 'resource-roles': async (filePath) => {
30- // const start = Date.now();
31- // await migrateResourceRoles(filePath);
32- // console.log(`⏱️ Duration: ${((Date.now() - start) / 1000).toFixed(2)}s.`);
33- // },
34- // 'resource-role-phase-dependencies': async (filePath) => {
35- // const start = Date.now();
36- // await migrateResourceRolePhaseDependencies(filePath);
37- // console.log(`⏱️ Duration: ${((Date.now() - start) / 1000).toFixed(2)}s.`);
38- // },
19+ 'member-profiles' : async ( filePath ) => {
20+ const start = Date . now ( )
21+ await migrateMemberProfilesAuto ( filePath )
22+ console . log ( `⏱️ Duration: ${ ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 2 ) } s.` )
23+ } ,
24+ 'member-stats' : async ( filePath ) => {
25+ const start = Date . now ( )
26+ await migrateMemberStatsAuto ( filePath )
27+ console . log ( `⏱️ Duration: ${ ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 2 ) } s.` )
28+ } ,
29+ 'resource-roles' : async ( filePath ) => {
30+ const start = Date . now ( )
31+ await migrateResourceRoles ( filePath )
32+ console . log ( `⏱️ Duration: ${ ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 2 ) } s.` )
33+ } ,
34+ 'resource-role-phase-dependencies' : async ( filePath ) => {
35+ const start = Date . now ( )
36+ await migrateResourceRolePhaseDependencies ( filePath )
37+ console . log ( `⏱️ Duration: ${ ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 2 ) } s.` )
38+ } ,
3939 'resources' : async ( filePath ) => {
40- const start = Date . now ( ) ;
41- await migrateResourceAuto ( filePath ) ;
42- console . log ( `⏱️ Duration: ${ ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 2 ) } s.` ) ;
40+ const start = Date . now ( )
41+ await migrateResourceAuto ( filePath )
42+ console . log ( `⏱️ Duration: ${ ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 2 ) } s.` )
4343 }
4444} ;
4545
4646// === EXECUTION ENTRYPOINT ===
4747// Determines which migration step to execute and handles file path input
4848( async ( ) => {
49- const step = process . argv [ 2 ] ; // First argument: migration step name
50- const customPath = process . argv [ 3 ] ; // Second argument (optional): custom file path
49+ const step = process . argv [ 2 ] // First argument: migration step name
50+ const customPath = process . argv [ 3 ] // Second argument (optional): custom file path
5151
5252 // Default file paths for each step
5353 const defaultPaths = {
@@ -56,32 +56,32 @@ const steps = {
5656 'resource-roles' : './data/ResourceRole_dynamo_data.json' ,
5757 'resource-role-phase-dependencies' : './data/ResourceRolePhaseDependency_dynamo_data.json' ,
5858 'resources' : './data/Resource_data.json'
59- } ;
59+ }
6060
6161 // Show help if step is invalid
6262 if ( ! steps [ step ] ) {
63- console . log ( '❌ Invalid migration step.\nUsage:' ) ;
64- console . log ( ' node src/index.js <step-name> [custom-path]' ) ;
65- console . log ( '\nAvailable steps:' ) ;
66- console . log ( Object . keys ( steps ) . map ( s => ` - ${ s } ` ) . join ( '\n' ) ) ;
67- process . exit ( 1 ) ;
63+ console . log ( '❌ Invalid migration step.\nUsage:' )
64+ console . log ( ' node src/index.js <step-name> [custom-path]' )
65+ console . log ( '\nAvailable steps:' )
66+ console . log ( Object . keys ( steps ) . map ( s => ` - ${ s } ` ) . join ( '\n' ) )
67+ process . exit ( 1 )
6868 }
6969
70- const filePath = customPath || path . join ( defaultPaths [ step ] ) ;
70+ const filePath = customPath || path . join ( defaultPaths [ step ] )
7171
7272 // Validate file existence
7373 if ( ! fs . existsSync ( filePath ) ) {
74- console . error ( `❌ File not found: ${ filePath } ` ) ;
75- process . exit ( 1 ) ;
74+ console . error ( `❌ File not found: ${ filePath } ` )
75+ process . exit ( 1 )
7676 }
7777
7878 // Run selected migration step
7979 try {
80- console . log ( `🚀 Starting ${ step } migration from ${ filePath } ` ) ;
81- await steps [ step ] ( filePath ) ;
82- console . log ( `Step '${ step } ' completed successfully.` ) ;
80+ console . log ( `🚀 Starting ${ step } migration from ${ filePath } ` )
81+ await steps [ step ] ( filePath )
82+ console . log ( `Step '${ step } ' completed successfully.` )
8383 } catch ( error ) {
84- console . error ( `❌ Error during '${ step } ':` , error . message ) ;
85- process . exit ( 1 ) ;
84+ console . error ( `❌ Error during '${ step } ':` , error . message )
85+ process . exit ( 1 )
8686 }
87- } ) ( ) ;
87+ } ) ( )
0 commit comments