Skip to content

Commit 25de238

Browse files
authored
CCM-10057: user transfer data migration (#476)
1 parent 9f1b533 commit 25de238

25 files changed

+10842
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dist
3838
# misc
3939
.DS_Store
4040
*.pem
41+
data-migration/user-transfer/backups/
4142

4243
# debug
4344
npm-debug.log*
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"../../.eslintrc"
4+
]
5+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# User Transfer Data Migration
2+
3+
The purpose of this tool is to transfer templates stored in DynamoDB from one owner to another. It does not transfer ownership of any files in S3, this would need to be done separately.
4+
5+
The owner field is the partition key for database entries and as such they are deleted and re-created with the new owner. They will retain their unique ID.
6+
7+
A local backup of the data is persisted before any updates into a `./backup` directory.
8+
9+
## Parameters
10+
11+
| Parameter | Optional | Description |
12+
| ------------------ | -------- | ----------------------------------------------- |
13+
| --sourceOwner | Required | The current owner of the data, typically a UUID |
14+
| --destinationOwner | Required | The new owner of the data, typically a UUID |
15+
| --environment | Required | The environment name, e.g. main |
16+
| | | |
17+
18+
## Authentication
19+
20+
You should establish a local AWS authentication session to the target AWS account with sufficient permissions to read, write and delete template data from DynamoDB.
21+
22+
## Example
23+
24+
```shell
25+
npm run transfer -- --sourceOwner 26d202d4-f001-7043-1781-77c935224d18 --destinationOwner e6f232b4-6051-7096-a238-5527b8615d11 --environment main
26+
```
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* For a detailed explanation regarding each configuration property, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
import type { Config } from 'jest';
7+
import { pathsToModuleNameMapper } from 'ts-jest';
8+
import { compilerOptions } from './tsconfig.json';
9+
10+
const config: Config = {
11+
preset: 'ts-jest',
12+
13+
// Automatically clear mock calls, instances, contexts and results before every test
14+
clearMocks: true,
15+
16+
// Indicates whether the coverage information should be collected while executing the test
17+
collectCoverage: true,
18+
19+
// The directory where Jest should output its coverage files
20+
coverageDirectory: './.reports/unit/coverage',
21+
22+
// Indicates which provider should be used to instrument code for coverage
23+
coverageProvider: 'v8',
24+
25+
coverageThreshold: {
26+
global: {
27+
branches: 100,
28+
functions: 100,
29+
lines: 100,
30+
statements: -10,
31+
},
32+
},
33+
34+
collectCoverageFrom: ['src/**/*.ts*'],
35+
36+
coveragePathIgnorePatterns: ['handler.ts', 'constants.ts'],
37+
38+
// Set the absolute path for imports
39+
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
40+
prefix: '<rootDir>/',
41+
}),
42+
43+
// Use this configuration option to add custom reporters to Jest
44+
reporters: [
45+
'default',
46+
[
47+
'../../node_modules/jest-html-reporter',
48+
{
49+
pageTitle: 'Test Report',
50+
outputPath: './.reports/unit/test-report.html',
51+
includeFailureMsg: true,
52+
},
53+
],
54+
],
55+
56+
// The test environment that will be used for testing
57+
testEnvironment: 'node',
58+
59+
testPathIgnorePatterns: ['/node_modules/', '/tests/'],
60+
};
61+
62+
export default config;

0 commit comments

Comments
 (0)