Add missing team->user constraint (#4411)

* Add missing team->user constraint

* fix: teamPermanentDeleter cannot complete when team has domains
This commit is contained in:
Tom Moor
2022-11-11 09:40:52 -08:00
committed by GitHub
parent 26946853da
commit 6788005115
2 changed files with 19 additions and 7 deletions

View File

@@ -175,13 +175,6 @@ async function teamPermanentDeleter(team: Team) {
force: true,
transaction,
});
await User.destroy({
where: {
teamId,
},
force: true,
transaction,
});
await team.destroy({
force: true,
transaction,

View File

@@ -0,0 +1,19 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.changeColumn("users", "teamId", {
type: Sequelize.UUID,
onDelete: "cascade",
references: {
model: "teams",
},
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.changeColumn("users", "teamId", {
type: Sequelize.UUID,
});
}
};