Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue-131]: Check email existence #135

Merged
merged 3 commits into from
Feb 26, 2020
Merged
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ If the playground is turned on, you can access it via `/graphql` route.

To execute the request, enter it in the input field on the left and click on the request execution button.
On the right side you will see the result of the query.

## Migrations

Run `yarn migrations:up` command to apply migration revisions or
`yarn migrations:down` to rollback the last revision.
8 changes: 4 additions & 4 deletions migrate-mongo-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file Configuration for migrate-mongo (https://www.npmjs.com/package/migrate-mongo)
*/

require('./src/env');
require('dotenv').config();

const config = {
mongodb: {
Expand All @@ -16,8 +16,8 @@ const config = {
/**
* Removes a deprecation warning when connecting
*/
useUnifiedTopology: true
}
useUnifiedTopology: true,
},
},

/**
Expand All @@ -28,7 +28,7 @@ const config = {
/**
* The mongodb collection where the applied changes are stored. Only edit this when really necessary
*/
changelogCollectionName: 'changelog'
changelogCollectionName: 'changelog',
};

module.exports = config;
22 changes: 22 additions & 0 deletions migrations/20200224203115-add-index-to-users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @file Migration to add unique index for `email` field from users collection
*/
module.exports = {
async up(db) {
const collection = db.collection('users');

await collection.createIndex({
email: 1,
}, {
unique: true,
});
},

async down(db) {
const collection = db.collection('users');

await collection.dropIndex({
email: 1,
});
},
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"dev:up": "docker-compose -f docker-compose.dev.yml up -d",
"dev:down": "docker-compose -f docker-compose.dev.yml down",
"build": "tsc && yarn copy-email-templates",
"copy-email-templates": "copyfiles src/email/templates/*/*.txt build"
"copy-email-templates": "copyfiles src/email/templates/*/*.txt build",
"migrations:up": "docker-compose exec api yarn migrate-mongo up",
"migrations:down": "docker-compose exec api yarn migrate-mongo down"
},
"husky": {
"hooks": {
Expand Down