Skip to content

Commit

Permalink
Merge branch 'trunk' into snyk-upgrade-7914aea754b5fa005ce14875a295e555
Browse files Browse the repository at this point in the history
  • Loading branch information
delagroove authored Dec 2, 2021
2 parents bc72ea3 + 36179e8 commit 68ecee5
Show file tree
Hide file tree
Showing 12 changed files with 21,650 additions and 2,079 deletions.
21 changes: 21 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ jobs:

- run: npm run lint

test-integration:
docker:
- image: circleci/node:14.11.0-stretch
# Integration tests need MongoDB server running and accessible on port 27017
- image: circleci/mongo:4.2.0
command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
ports:
- "27017:27017"
steps:
- checkout
- run:
name: Run Integration Tests
environment:
MONGO_URL: mongodb://localhost:27017/test
MONGO_USE_UNIFIED_TOPOLOGY: false
command: npx --quiet --package @reactioncommerce/ci-scripts@1.12.2 run-integration-tests

workflows:
version: 2
build_deploy:
Expand All @@ -57,10 +74,14 @@ workflows:
- lint:
requires:
- build
- test-integration:
requires:
- build
- deploy:
context: reaction-publish-semantic-release
requires:
- lint
- test-integration
filters:
branches:
only: trunk
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import register from "./src/index.js";

export { default as migrations } from "./migrations/index.js";

export default register;
24 changes: 24 additions & 0 deletions migrations/2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @summary adds createdAt and updatedAt fields to the current collection and assigns it to 01-01-1970
* @param {Object} args - the arguments
* @param {Object} args.db - the DB client
* @param {Function} args.progress - a function to set the progress of the operation
* @returns {undefined}
*/
async function up({ db, progress }) {
progress(0);

const date = new Date(1970, 0, 1);
const query = { createdAt: { $exists: false }, updatedAt: { $exists: false } };
const update = { $set: { createdAt: date, updatedAt: date } };
const options = { upsert: false, multi: true };

await db.collection("Emails").update(query, update, options);

progress(100);
}

export default {
down: "unnecessary",
up
};
13 changes: 13 additions & 0 deletions migrations/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { migrationsNamespace } from "./migrationsNamespace.js";
import migration2 from "./2.js";

export default {
tracks: [
{
namespace: migrationsNamespace,
migrations: {
2: migration2
}
}
]
};
1 change: 1 addition & 0 deletions migrations/migrationsNamespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const migrationsNamespace = "email";
Loading

0 comments on commit 68ecee5

Please sign in to comment.