0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added unique constraint to email_spam_complaint_events table

We can fetch the same event multiple times from Mailgun so we need to
be able to protect against inserting duplicate events in the
database. This will allow us to catch duplicate errors on insert when
handling complaint events.
This commit is contained in:
Fabien "egg" O'Carroll 2022-11-30 22:48:58 +07:00
parent f9fdee1b28
commit c0e91c73d3
3 changed files with 9 additions and 3 deletions

View file

@ -5,5 +5,8 @@ module.exports = addTable('email_spam_complaint_events', {
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
email_id: {type: 'string', maxlength: 24, nullable: false, references: 'emails.id'},
email_address: {type: 'string', maxlength: 191, nullable: false, unique: false},
created_at: {type: 'dateTime', nullable: false}
created_at: {type: 'dateTime', nullable: false},
'@@UNIQUE_CONSTRAINTS@@': [
['email_id', 'member_id']
]
});

View file

@ -972,6 +972,9 @@ module.exports = {
member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
email_id: {type: 'string', maxlength: 24, nullable: false, references: 'emails.id'},
email_address: {type: 'string', maxlength: 191, nullable: false, unique: false, validations: {isEmail: true}},
created_at: {type: 'dateTime', nullable: false}
created_at: {type: 'dateTime', nullable: false},
'@@UNIQUE_CONSTRAINTS@@': [
['email_id', 'member_id']
]
}
};

View file

@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
*/
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '7376b855d023c40d1c0ff5770d1d01fd';
const currentSchemaHash = 'aa2f277e624b5fbe5f18cb0d78ff18f4';
const currentFixturesHash = 'dcb7ba7c66b4b98d6c26a722985e756a';
const currentSettingsHash = '9acce72858e75420b831297718595bbd';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';