mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🐛 Fixed 3.0 migration for SQLite (#11270)
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
This commit is contained in:
parent
fbcefeb826
commit
99c6351feb
1 changed files with 5 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue