0
Fork 0
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:
Naz Gargol 2019-10-28 14:21:21 +01:00 committed by GitHub
parent fbcefeb826
commit 99c6351feb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();