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

Fixed email_recipients indexes to match query usage #19918

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,17 @@
// For information on writing migrations, see https://www.notion.so/ghost/Database-migrations-eb5b78c435d741d2b34a582d57c24253

const {createNonTransactionalMigration} = require('../../utils');
const commands = require('../../../schema/commands');

module.exports = createNonTransactionalMigration(
async function up(knex) {
await commands.addIndex('email_recipients', ['email_id', 'delivered_at'], knex);
await commands.addIndex('email_recipients', ['email_id', 'opened_at'], knex);
await commands.addIndex('email_recipients', ['email_id', 'failed_at'], knex);
},
async function down(knex) {
await commands.dropIndex('email_recipients', ['email_id', 'delivered_at'], knex);
await commands.dropIndex('email_recipients', ['email_id', 'opened_at'], knex);
await commands.dropIndex('email_recipients', ['email_id', 'failed_at'], knex);
}
);
@@ -0,0 +1,17 @@
// For information on writing migrations, see https://www.notion.so/ghost/Database-migrations-eb5b78c435d741d2b34a582d57c24253

const {createNonTransactionalMigration} = require('../../utils');
const commands = require('../../../schema/commands');

module.exports = createNonTransactionalMigration(
async function up(knex) {
await commands.dropIndex('email_recipients', ['delivered_at'], knex);
await commands.dropIndex('email_recipients', ['opened_at'], knex);
await commands.dropIndex('email_recipients', ['failed_at'], knex);
},
async function down(knex) {
await commands.addIndex('email_recipients', ['delivered_at'], knex);
await commands.addIndex('email_recipients', ['opened_at'], knex);
await commands.addIndex('email_recipients', ['failed_at'], knex);
}
);
11 changes: 7 additions & 4 deletions ghost/core/core/server/data/schema/schema.js
Expand Up @@ -865,14 +865,17 @@ module.exports = {
member_id: {type: 'string', maxlength: 24, nullable: false, index: true},
batch_id: {type: 'string', maxlength: 24, nullable: false, references: 'email_batches.id'},
processed_at: {type: 'dateTime', nullable: true},
delivered_at: {type: 'dateTime', nullable: true, index: true},
opened_at: {type: 'dateTime', nullable: true, index: true},
failed_at: {type: 'dateTime', nullable: true, index: true},
delivered_at: {type: 'dateTime', nullable: true},
opened_at: {type: 'dateTime', nullable: true},
failed_at: {type: 'dateTime', nullable: true},
member_uuid: {type: 'string', maxlength: 36, nullable: false},
member_email: {type: 'string', maxlength: 191, nullable: false},
member_name: {type: 'string', maxlength: 191, nullable: true},
'@@INDEXES@@': [
['email_id', 'member_email']
['email_id', 'member_email'],
['email_id', 'delivered_at'],
['email_id', 'opened_at'],
['email_id', 'failed_at']
]
},
email_recipient_failures: {
Expand Down
2 changes: 1 addition & 1 deletion ghost/core/test/unit/server/data/schema/integrity.test.js
Expand Up @@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
*/
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '34a9fa4dc1223ef6c45f8ed991d25de5';
const currentSchemaHash = 'ccf3893bc3f8930f0d1188e646abda6d';
const currentFixturesHash = 'a489d615989eab1023d4b8af0ecee7fd';
const currentSettingsHash = '5c957ceb48c4878767d7d3db484c592d';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
Expand Down