Delete also map pool maps when group is deleted

This commit is contained in:
Kalle
2023-08-26 13:36:51 +03:00
parent 768fc62b2c
commit 11c7302fc7
2 changed files with 12 additions and 0 deletions

View File

@@ -18,6 +18,11 @@ const deleteGroupStm = sql.prepare(/* sql */ `
where "Group"."id" = @groupId
`);
const deleteGroupMapsStm = sql.prepare(/* sql */ `
delete from "MapPoolMap"
where "groupId" = @groupId
`);
export const leaveGroup = sql.transaction(
({
groupId,
@@ -40,6 +45,7 @@ export const leaveGroup = sql.transaction(
deleteGroupMemberStm.run({ groupId, userId });
} else {
deleteGroupStm.run({ groupId });
deleteGroupMapsStm.run({ groupId });
}
}
);

View File

@@ -5,6 +5,11 @@ const deleteGroupStm = sql.prepare(/* sql */ `
where "Group"."id" = @groupId
`);
const deleteGroupMapsStm = sql.prepare(/* sql */ `
delete from "MapPoolMap"
where "groupId" = @groupId
`);
const addGroupMemberStm = sql.prepare(/* sql */ `
insert into "GroupMember" ("groupId", "userId", "role")
values (@groupId, @userId, @role)
@@ -27,6 +32,7 @@ export const morphGroups = sql.transaction(
newMembers: number[];
}) => {
deleteGroupStm.run({ groupId: otherGroupId });
deleteGroupMapsStm.run({ groupId: otherGroupId });
deleteLikesStm.run({ groupId: survivingGroupId });