From 021cd253af067932619f9761308e5f51f58f059b Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 28 Feb 2024 22:49:34 -0500 Subject: [PATCH] fix: Missing SET NULL on shares relationship. closes #6609 --- ...0240229034214-search-query-relationship.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server/migrations/20240229034214-search-query-relationship.js diff --git a/server/migrations/20240229034214-search-query-relationship.js b/server/migrations/20240229034214-search-query-relationship.js new file mode 100644 index 000000000..7b8111122 --- /dev/null +++ b/server/migrations/20240229034214-search-query-relationship.js @@ -0,0 +1,26 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.removeConstraint("search_queries", "search_queries_shareId_fkey") + await queryInterface.changeColumn("search_queries", "shareId", { + type: Sequelize.UUID, + allowNull: true, + onDelete: "SET NULL", + references: { + model: "shares", + }, + }); + }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.removeConstraint("search_queries", "search_queries_shareId_fkey") + await queryInterface.changeColumn("search_queries", "shareId", { + type: Sequelize.UUID, + allowNull: true, + references: { + model: "shares", + }, + }); + } +};