Skip to content

Commit

Permalink
Merge pull request #1414 from SciCatProject/swap-4073-single-dataset-…
Browse files Browse the repository at this point in the history
…schema

refactor: prep for unified dataset schema
  • Loading branch information
nitrosx authored Sep 20, 2024
2 parents 884f77b + c5e1040 commit 1f8c98d
Show file tree
Hide file tree
Showing 25 changed files with 1,224 additions and 288 deletions.
47 changes: 47 additions & 0 deletions migrations/20240920111733-dataset-unified-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = {
async up(db, client) {
// TODO write your migration here.
// See https://github.com/seppevs/migrate-mongo/#creating-a-new-migration-script
// Example:
// await db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: true}});
await db.collection("Dataset").updateMany({}, [
{
$set: {
proposalIds: ["$proposalId"],
instrumentIds: ["$instrumentId"],
sampleIds: ["$sampleId"],
},
},
]);
await db.collection("Dataset").updateMany({ type: "derived" }, [
{
$set: {
principalInvestigator: "$investigator",
},
},
]);
},

async down(db, client) {
// TODO write the statements to rollback your migration (if possible)
// Example:
// await db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: false}});

await db.collection("Dataset").updateMany({}, [
{
$set: {
proposalId: "$proposalIds[0]",
instrumentId: "$instrumentId[0]",
sampleId: "$sampleId[0]",
},
},
]);
await db.collection("Dataset").updateMany({ type: "derived" }, [
{
$set: {
investigator: "$principalInvestigator",
},
},
]);
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:api": "npm run test:api:jest --maxWorkers=50% && concurrently -k -s first \"wait-on http://localhost:3000/explorer/ && npm run test:api:mocha\" \"npm run start\"",
"test:api:jest": "jest --config ./test/config/jest-e2e.json --maxWorkers=50%",
"test:api:mocha": "mocha --config ./test/config/.mocharc.json -r chai/register-should.js ",
"test:api:mocha": "mocha --config ./test/config/.mocharc.json -r chai/register-should.js",
"prepare:local": "docker-compose -f CI/E2E/docker-compose-local.yaml --env-file CI/E2E/.env.elastic-search up -d && cp functionalAccounts.json.test functionalAccounts.json"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 1f8c98d

Please sign in to comment.