-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug(sendgrid):Fix sendgrid email bug
Use try catch to console log sendgrid email limit error [Finishes #167215236]
- Loading branch information
1 parent
467cbd7
commit 059e2b8
Showing
3 changed files
with
98 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Comments', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
commentBody: { | ||
type: Sequelize.TEXT | ||
}, | ||
userId: { | ||
type: Sequelize.INTEGER, | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Users', | ||
key: 'id', | ||
as: 'userId' | ||
} | ||
}, | ||
articleId: { | ||
type: Sequelize.INTEGER, | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Articles', | ||
key: 'id', | ||
as: 'articleId' | ||
} | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP') | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP') | ||
} | ||
}), | ||
down: queryInterface => queryInterface.dropTable('Comments') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const comment = (sequelize, DataTypes) => { | ||
const Comment = sequelize.define('Comment', { | ||
commentBody: { | ||
type: DataTypes.STRING | ||
}, | ||
userId: { | ||
type: DataTypes.INTEGER, | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Users', | ||
key: 'id', | ||
as: 'userId' | ||
} | ||
}, | ||
articleId: { | ||
type: DataTypes.INTEGER, | ||
onDelete: 'CASCADE', | ||
references: { | ||
model: 'Articles', | ||
key: 'id', | ||
as: 'articleId' | ||
} | ||
}, | ||
}); | ||
|
||
Comment.associate = (models) => { | ||
// associations can be defined here | ||
Comment.belongsTo(models.User, { | ||
as: 'userComments', | ||
foriegnKey: 'userId', | ||
onDelete: 'CASCADE' | ||
}); | ||
Comment.belongsTo(models.Article, { | ||
foreignKey: 'articleId', | ||
as: 'article', | ||
onDelete: 'CASCADE', | ||
onUpdate: 'CASCADE' | ||
}); | ||
}; | ||
return Comment; | ||
}; | ||
export default comment; |