-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3532 from OriginTrail/v8/migration/triple-store-u…
…ser-config-migration V8/migration/triple store user config migration
- Loading branch information
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import appRootPath from 'app-root-path'; | ||
import path from 'path'; | ||
import BaseMigration from './base-migration.js'; | ||
|
||
class TripleStoreUserConfigurationMigration extends BaseMigration { | ||
async executeMigration() { | ||
const configurationFolderPath = path.join(appRootPath.path, '..'); | ||
const configurationFilePath = path.join( | ||
configurationFolderPath, | ||
this.config.configFilename, | ||
); | ||
|
||
const userConfiguration = await this.fileService.readFile(configurationFilePath, true); | ||
|
||
if ('tripleStore' in userConfiguration.modules) { | ||
const oldConfigTripleStore = userConfiguration.modules; | ||
for (const implementation in oldConfigTripleStore.tripleStore.implementation) { | ||
if (oldConfigTripleStore.tripleStore.implementation[implementation].enabled) { | ||
const { url, username, password } = | ||
oldConfigTripleStore.tripleStore.implementation[implementation].config | ||
.repositories.publicCurrent; | ||
|
||
oldConfigTripleStore.tripleStore.implementation[ | ||
implementation | ||
].config.repositories.dkg = { | ||
url, | ||
name: 'dkg', | ||
username, | ||
password, | ||
}; | ||
} | ||
} | ||
|
||
await this.fileService.writeContentsToFile( | ||
configurationFolderPath, | ||
this.config.configFilename, | ||
JSON.stringify(userConfiguration, null, 4), | ||
); | ||
} | ||
} | ||
} | ||
|
||
export default TripleStoreUserConfigurationMigration; |
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