mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03:00
🐛 Fixed migration for SQLite3 (#12371)
no-issue The current version of SQLite3 bundled with Ghost supports a maximum of 999 variables, we use one variable for the SET value and so we're left with 998 for the WHERE IN clause values. refs: https://forum.ghost.org/t/unable-to-start-ghost-3-38-0-locally/18322
This commit is contained in:
parent
6b8bfb81fc
commit
8ad995203e
@ -1,3 +1,4 @@
|
||||
const {chunk} = require('lodash');
|
||||
const {createTransactionalMigration} = require('../../utils');
|
||||
const logging = require('../../../../../shared/logging');
|
||||
|
||||
@ -17,13 +18,24 @@ module.exports = createTransactionalMigration(
|
||||
.select('id')
|
||||
.where('visibility', 'public')).map(row => row.id);
|
||||
|
||||
await connection('emails')
|
||||
.update('recipient_filter', 'paid')
|
||||
.whereIn('post_id', paidPostIds);
|
||||
// Umm? Well... The current version of SQLite3 bundled with Ghost supports
|
||||
// a maximum of 999 variables, we use one variable for the SET value
|
||||
// and so we're left with 998 for our WHERE IN clause values
|
||||
const chunkSize = 998;
|
||||
const paidPostIdChunks = chunk(paidPostIds, chunkSize);
|
||||
const membersAndPublicPostIdChunks = chunk(membersPostIds.concat(publicPostIds), chunkSize);
|
||||
|
||||
await connection('emails')
|
||||
.update('recipient_filter', 'all')
|
||||
.whereIn('post_id', membersPostIds.concat(publicPostIds));
|
||||
for (const paidPostIdsChunk of paidPostIdChunks) {
|
||||
await connection('emails')
|
||||
.update('recipient_filter', 'paid')
|
||||
.whereIn('post_id', paidPostIdsChunk);
|
||||
}
|
||||
|
||||
for (const membersAndPublicPostIdsChunk of membersAndPublicPostIdChunks) {
|
||||
await connection('emails')
|
||||
.update('recipient_filter', 'all')
|
||||
.whereIn('post_id', membersAndPublicPostIdsChunk);
|
||||
}
|
||||
},
|
||||
|
||||
async function down(connection) {
|
||||
|
Loading…
Reference in New Issue
Block a user