/// migrate((app) => { const collection = app.findCollectionByNameOrId("pbc_2992844423") // update collection data unmarshal({ "viewQuery": "select \n (ROW_NUMBER() OVER()) as id,\n `Dvn1`.`policyNumber` as dvn_patient, \n `Dorz1`.`policyNumber` as dorz_patient\nfrom `Dorz1` \n join `Dvn1` on `Dvn1`.`policyNumber` = `Dorz1`.`policyNumber`\n" }, collection) // remove field collection.fields.removeById("_clone_wFQB") // remove field collection.fields.removeById("number432430951") // add field collection.fields.addAt(1, new Field({ "autogeneratePattern": "", "hidden": false, "id": "_clone_dN9O", "max": 0, "min": 0, "name": "dvn_patient", "pattern": "", "presentable": false, "primaryKey": false, "required": false, "system": false, "type": "text" })) // add field collection.fields.addAt(2, new Field({ "autogeneratePattern": "", "hidden": false, "id": "_clone_qJPB", "max": 0, "min": 0, "name": "dorz_patient", "pattern": "", "presentable": false, "primaryKey": false, "required": false, "system": false, "type": "text" })) return app.save(collection) }, (app) => { const collection = app.findCollectionByNameOrId("pbc_2992844423") // update collection data unmarshal({ "viewQuery": "select \n (ROW_NUMBER() OVER()) as id,\n policyNumber, \n count(policyNumber) as cnt\nfrom `Dorz1` \ngroup by policyNumber\nhaving cnt > 1;" }, collection) // add field collection.fields.addAt(1, new Field({ "autogeneratePattern": "", "hidden": false, "id": "_clone_wFQB", "max": 0, "min": 0, "name": "policyNumber", "pattern": "", "presentable": false, "primaryKey": false, "required": false, "system": false, "type": "text" })) // add field collection.fields.addAt(2, new Field({ "hidden": false, "id": "number432430951", "max": null, "min": null, "name": "cnt", "onlyInt": false, "presentable": false, "required": false, "system": false, "type": "number" })) // remove field collection.fields.removeById("_clone_dN9O") // remove field collection.fields.removeById("_clone_qJPB") return app.save(collection) })