-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfull-synchronization.js
More file actions
31 lines (21 loc) · 1.24 KB
/
Copy pathfull-synchronization.js
File metadata and controls
31 lines (21 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const dotenv = require('dotenv')
dotenv.config();
const importModernDatabase = require('./src/import-modern-database');
const { openModernConnection, openLegacyConnection, tablePrefix, openSynchronizationMSSQLConnection} = require("./src/connection");
const GeneralRepository = require("./src/repository/mssql/general-repository");
const SynchronizationRepository = require("./src/repository/mssql/synchronization-repository");
async function main() {
const legacyDbConnection = await openLegacyConnection();
const modernDbConnection = await openModernConnection();
const syncConnection = await openSynchronizationMSSQLConnection();
const legacyRepository = new GeneralRepository(legacyDbConnection.pool, tablePrefix);
const modernRepository = new GeneralRepository(modernDbConnection.pool, tablePrefix);
const synchronizationRepository = new SynchronizationRepository(syncConnection.pool, tablePrefix);
await synchronizationRepository.prepareStatements();
await importModernDatabase(legacyRepository, modernRepository, synchronizationRepository);
await synchronizationRepository.unprepareStatements();
await modernDbConnection.close();
await legacyDbConnection.close();
await syncConnection.close();
}
main();