Skip to content

Commit

Permalink
🐛 Fixed migrations for SQLite database users (#19839) (#21063)
Browse files Browse the repository at this point in the history
refs #19839
refs https://www.sqlite.org/limits.html

SQLite has limit of 500 items in a compound select statement.

This limit could be hit when a complex select statement was being
generated as part of a batch insert statement.

Lowering the batch size will have minimal impact on migration
performance while improving SQLite compatibility.

One of these bulk inserts is confirmed to be affected through the linked
issue.

I didn't confirm if the other two cases would trigger it, but the change
won't hurt there either.
  • Loading branch information
markstos authored Nov 5, 2024
1 parent 88db66a commit c8dcbbf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const insertPostCollections = async (knex, collectionId, postIds) => {
};
});

await knex.batchInsert('collections_posts', collectionPosts, 1000);
await knex.batchInsert('collections_posts', collectionPosts, 100);
};

module.exports = createTransactionalMigration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const insertPostCollections = async (knex, collectionId, postIds) => {
};
});

await knex.batchInsert('collections_posts', collectionPosts, 1000);
await knex.batchInsert('collections_posts', collectionPosts, 100);
};

module.exports = createTransactionalMigration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = createTransactionalMigration(
};
});
// Batch insert rows into the offer_redemptions table
await knex.batchInsert('offer_redemptions', offerRedemptions, 1000);
await knex.batchInsert('offer_redemptions', offerRedemptions, 100);
} else {
logging.info('No offer redemptions to backfill');
}
Expand Down

0 comments on commit c8dcbbf

Please sign in to comment.