Files
outline/server/migrations/20251212232500-add-integrations-service-type-settings-indexes.js
Copilot d5dbf286cc Add missing database indexes for hooks.unfurl endpoint (#10870)
* Initial plan

* Add database indexes to improve hooks.unfurl performance

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

* Verify migrations and query plans for new indexes

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

* Address code review feedback: improve migration rollback order and add comments

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

* Change index column order to teamId first as requested

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

* Update .env.test

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
2025-12-12 19:02:20 -05:00

28 lines
843 B
JavaScript

"use strict";
module.exports = {
async up(queryInterface, Sequelize) {
// Add composite index on service and type for better filtering
await queryInterface.addIndex("integrations", ["service", "type"], {
name: "integrations_service_type",
});
// Add GIN index on settings for JSONB queries
// Using raw SQL as Sequelize doesn't support GIN index type natively
await queryInterface.sequelize.query(
'CREATE INDEX "integrations_settings_gin" ON "integrations" USING GIN ("settings");'
);
},
async down(queryInterface, Sequelize) {
// Drop indexes in reverse order of creation
await queryInterface.sequelize.query(
'DROP INDEX IF EXISTS "integrations_settings_gin";'
);
await queryInterface.removeIndex(
"integrations",
"integrations_service_type"
);
},
};