diff --git a/server/migrations/20261123070000-add-subscriptions-document-id-index.js b/server/migrations/20261123070000-add-subscriptions-document-id-index.js new file mode 100644 index 0000000000..19ab6779fd --- /dev/null +++ b/server/migrations/20261123070000-add-subscriptions-document-id-index.js @@ -0,0 +1,17 @@ +"use strict"; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface) { + // Covers the foreign key cascade when a document is permanently deleted. + await queryInterface.sequelize.query( + 'CREATE INDEX CONCURRENTLY IF NOT EXISTS "subscriptions_document_id" ON "subscriptions" ("documentId");' + ); + }, + + async down(queryInterface) { + await queryInterface.sequelize.query( + 'DROP INDEX CONCURRENTLY IF EXISTS "subscriptions_document_id";' + ); + }, +};