-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
58 lines (52 loc) · 1.89 KB
/
main.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// @ts-check
const { program } = require("commander");
const { parseParallelism } = require("./utils.js");
const { runMigration } = require("./migrate.js");
// Start the program - first time
// Provide the startTime, collection, index and how many minutes of writes the destination db needs to catch up each time.
// Number of iterations are configurable
// With DURATION=30 and ITERATIONS=10, it migrates 30 mins worth of data from source db and does this 10 times,
// waiting WAIT_TIME seconds between each iteration.
program
.name("fauna-db-sync")
.description("migrates lastest writes from one DB to another")
.version("0.0.0", "-v, --version")
.usage("[OPTIONS]...")
.requiredOption("-s, --source <string>", "admin secret for the source DB")
.requiredOption("-t, --target <string>", "admin secret for the target DB")
.requiredOption(
"-d, --timestamp <number>",
"the timestamp from which to start syncing",
parseInt,
)
.option(
"-c, --collections <string...>",
"[optional] the list of Collection names to be sync'ed. If not provided, all collections will be sync'ed.",
)
.option(
"-i, --indexes <string...>",
"[optional] the list of Index names to be used with the respective Collections listed",
)
.option(
"-p, --parallelism <number>",
"[optional] apply up to N events per transaction",
parseParallelism,
10,
)
.option(
"--validate <number>",
"[optional] paginate through documents N at a time (1000 max) and compare source to target; WARNING: this could take a long time and will accrue additional read ops",
parseInt,
)
.option(
"--endpoint <string>",
"[optional] the endpoint to use for the source and target DBs",
"https://db.fauna.com",
)
.option(
"-y, --yes",
"[optional] skip confirmation prompts and run the migration",
)
.parse(process.argv);
const options = program.opts();
runMigration(options);