perf: Add partial createdAt index for stuck import task scan (#14565)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-12 18:59:43 -05:00
1 parent d066c98bde
commit e262f3bd17
1 file changed
+17
@@ -0,0 +1,17 @@
"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface) {
// Covers the scan for stuck import tasks, which pages by createdAt.
await queryInterface.sequelize.query(
`CREATE INDEX CONCURRENTLY IF NOT EXISTS "import_tasks_pending_created_at" ON "import_tasks" ("createdAt", "id") WHERE "state" IN ('created', 'in_progress');`
);
},
async down(queryInterface) {
await queryInterface.sequelize.query(
'DROP INDEX CONCURRENTLY IF EXISTS "import_tasks_pending_created_at";'
);
},
};