Skip to content

Commit

Permalink
馃悰 Fixed 3.0 migration for SQLite (#11270)
Browse files Browse the repository at this point in the history
closes #11263

- Fixed `3.0/05-populate-posts-meta-table.js` migration failure when having >999 posts with metadata in the database
- The issue here is with hitting SQLite's internal SQLITE_LIMIT_VARIABLE_NUMBER limit when updating with a large amount of posts having metadata fields set (ref.: https://sqlite.org/limits.html#max_variable_number)
- Transforming migration to iterative method avoided inserting lots of records at once
  • Loading branch information
naz committed Oct 28, 2019
1 parent fbcefeb commit 99c6351
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -42,7 +42,11 @@ module.exports.up = (options) => {
postsMetaEntry.id = ObjectId.generate();
return postsMetaEntry;
});
return localOptions.transacting('posts_meta').insert(postsMetaEntries);

// NOTE: iterative method is needed to prevent from `SQLITE_ERROR: too many variables` error
return Promise.map(postsMetaEntries, (postsMeta) => {
return localOptions.transacting('posts_meta').insert(postsMeta);
});
} else {
common.logging.info('Skipping populating posts_meta table: found 0 posts with metadata');
return Promise.resolve();
Expand Down

0 comments on commit 99c6351

Please sign in to comment.