Skip to content

Commit

Permalink
🐛 Fixed migrations for SQLite database users (#19839)
Browse files Browse the repository at this point in the history
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.

Ref: https://www.sqlite.org/limits.html
Issue: #19839
  • Loading branch information
markstos committed Sep 21, 2024
1 parent 2681e52 commit 8897c02
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, 450);
};

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, 450);
};

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, 450);
} else {
logging.info('No offer redemptions to backfill');
}
Expand Down

0 comments on commit 8897c02

Please sign in to comment.