Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commands/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = function(program, next) {
.option('-p, --project <project_id>', 'The project ID that you wish to clone from one database to another.')
.option('--forms <forms>', 'A comma-separated value of all the Form ID\'s you wish to clone. If included, then only the provided forms will be cloned.', false)
.option('--exclude <forms>', 'A comma-separated value of all the Form ID\'s you wish to exclude in the clone process.', false)
.option('--start-with <form_id>', 'The form ID to start cloning from.')
.option('-u, --update-existing', 'Update existing Projects and Forms instead of cloning (No OSS).', true)
.option('--update-existing-submissions', 'Update existing Submissions when found in the destination (slows down the clone process if set).', false)
.option('--src-ca <source_ca>', 'The TLS certificate authority for the source mongo url')
Expand Down
11 changes: 10 additions & 1 deletion src/Cloner.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,14 +905,17 @@ class Cloner {
process.stdout.write('\n');
process.stdout.write(' - Forms:');
let compsWithEncryptedData = [];
let started = true;
if (this.options.startWith) {
started = false;
}
await this.upsertAll('forms', this.formQuery(srcProject), (form) => {
process.stdout.write('\n');
process.stdout.write(`- Form: ${form.title} (${form._id})`);
}, async(src, update, dest) => {
if (this.options.submissionsOnly) {
return false;
}

await eachComponentAsync(update.components, async(component, path) => {
if (component.encrypted) {
compsWithEncryptedData.push(path);
Expand All @@ -923,6 +926,12 @@ class Cloner {
update.project = destProject._id;
this.migrateFormAccess(src, update);
}, async(srcForm, destForm) => {
if (!started && this.options.startWith && srcForm._id.toString() === this.options.startWith) {
started = true;
}
if (!started) {
return false;
}
if (this.options.deleteSubmissions) {
console.log(`Deleting submissions from ${destForm.title}`);
await this.dest.submissions.deleteMany(this.itemQuery({
Expand Down
Loading