From c0b12031999f61372452ceee80f956864400f2c2 Mon Sep 17 00:00:00 2001 From: jzunigax2 <125698953+jzunigax2@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:17:32 -0600 Subject: [PATCH] feat: add unique constraint on workspace_teams_users and workspace_users --- ...-memberid-workspaceid-on-workspaceusers.js | 19 +++++++++++++++++++ ...5-add-unique-constraint-memberid-teamid.js | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 migrations/20241104132055-add-unique-constraint-memberid-workspaceid-on-workspaceusers.js create mode 100644 migrations/20241104161535-add-unique-constraint-memberid-teamid.js diff --git a/migrations/20241104132055-add-unique-constraint-memberid-workspaceid-on-workspaceusers.js b/migrations/20241104132055-add-unique-constraint-memberid-workspaceid-on-workspaceusers.js new file mode 100644 index 00000000..a5fb1fe1 --- /dev/null +++ b/migrations/20241104132055-add-unique-constraint-memberid-workspaceid-on-workspaceusers.js @@ -0,0 +1,19 @@ +'use strict'; + +const tableName = 'workspace_users'; +const constraintName = 'workspace_users_member_id_workspace_id_key'; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface) { + await queryInterface.addConstraint(tableName, { + fields: ['member_id', 'workspace_id'], + type: 'unique', + name: constraintName, + }); + }, + + async down(queryInterface) { + await queryInterface.removeConstraint(tableName, constraintName); + }, +}; diff --git a/migrations/20241104161535-add-unique-constraint-memberid-teamid.js b/migrations/20241104161535-add-unique-constraint-memberid-teamid.js new file mode 100644 index 00000000..18d4082b --- /dev/null +++ b/migrations/20241104161535-add-unique-constraint-memberid-teamid.js @@ -0,0 +1,19 @@ +'use strict'; + +const table_name = 'workspace_teams_users'; +const constraintName = 'workspace_teams_users_member_id_team_id_key'; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface) { + await queryInterface.addConstraint(table_name, { + fields: ['member_id', 'team_id'], + type: 'unique', + name: constraintName, + }); + }, + + async down(queryInterface) { + await queryInterface.removeConstraint(table_name, constraintName); + }, +};