mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Update user deletion to reassign roles and fix foreign key constraint violations
Update the deleteUser function in DatabaseStorage to reassign roles assigned by the deleted user to the admin user, resolving a foreign key constraint error when deleting the 'system' user. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/vetH0Gp
This commit is contained in:
1 parent
c24e19da52
commit
fd92ce25d0
3 files changed
+115
-1
No files matched your search
+7
-1
@@ -420,10 +420,16 @@ export class DatabaseStorage implements IStorage {
|
||||
.set({ createdBy: adminUserId })
|
||||
.where(eq(nocodbConfig.createdBy, id));
|
||||
|
||||
// Update role assignments made BY this user (assignedBy field)
|
||||
await tx
|
||||
.update(userRoles)
|
||||
.set({ assignedBy: adminUserId })
|
||||
.where(eq(userRoles.assignedBy, id));
|
||||
|
||||
// Delete user-group assignments
|
||||
await tx.delete(userGroups).where(eq(userGroups.userId, id));
|
||||
|
||||
// Delete user-role assignments
|
||||
// Delete user-role assignments TO this user
|
||||
await tx.delete(userRoles).where(eq(userRoles.userId, id));
|
||||
|
||||
// Finally delete the user
|
||||
|
||||
Reference in new issue
Block a user