mattrax / Mattrax

Open source MDM for all your devices

Home Page:https://mattrax.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User deletions

oscartbeaumont opened this issue · comments

Properly handle delete users.

TODO:

  • Sync with EntraID

Delete all relatations including:

  • Device ownership
  • Group assignments
  • Policy/app direct assignments
Error: Cannot delete or update a parent row: a foreign key constraint fails (`mattrax`.`devices`, CONSTRAINT `devices_owner_users_pk_fk` FOREIGN KEY (`owner`) REFERENCES `users` (`pk`))
    at PromisePoolConnection.execute (/Users/oscar/Desktop/mattrax/node_modules/.pnpm/mysql2@3.9.7/node_modules/mysql2/promise.js:112:22)
    at eval (/Users/oscar/Desktop/mattrax/packages/mysql-planetscale/src/index.ts:54:54)
    at fetch (/Users/oscar/Desktop/mattrax/apps/web/src/db/index.ts:26:43)
    at postJSON (file:///Users/oscar/Desktop/mattrax/node_modules/.pnpm/@planetscale+database@1.18.0/node_modules/@planetscale/database/dist/index.js:125:28)
    at Connection.execute (file:///Users/oscar/Desktop/mattrax/node_modules/.pnpm/@planetscale+database@1.18.0/node_modules/@planetscale/database/dist/index.js:81:29)
    at Tx.execute (file:///Users/oscar/Desktop/mattrax/node_modules/.pnpm/@planetscale+database@1.18.0/node_modules/@planetscale/database/dist/index.js:34:26)
    at PlanetScalePreparedQuery.execute (file:///Users/oscar/Desktop/mattrax/node_modules/.pnpm/drizzle-orm@0.30.10_patch_hash=kbhw3lxqs5ui6og332q7mjjsdu_@cloudflare+workers-types@4.2024051_p7m3ncyjhy73fkeey37kfdlyfy/node_modules/drizzle-orm/planetscale-serverless/session.js:28:21)
    at QueryPromise.execute (file:///Users/oscar/Desktop/mattrax/node_modules/.pnpm/drizzle-orm@0.30.10_patch_hash=kbhw3lxqs5ui6og332q7mjjsdu_@cloudflare+workers-types@4.2024051_p7m3ncyjhy73fkeey37kfdlyfy/node_modules/drizzle-orm/mysql-core/query-builders/delete.js:61:27)
    at QueryPromise.then (file:///Users/oscar/Desktop/mattrax/node_modules/.pnpm/drizzle-orm@0.30.10_patch_hash=kbhw3lxqs5ui6og332q7mjjsdu_@cloudflare+workers-types@4.2024051_p7m3ncyjhy73fkeey37kfdlyfy/node_modules/drizzle-orm/query-promise.js:21:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ER_ROW_IS_REFERENCED_2',
  errno: 1451,
  sql: 'delete from `users` where `users`.`provider` = 5',
  sqlState: '23000',
  sqlMessage: 'Cannot delete or update a parent row: a foreign key constraint fails (`mattrax`.`devices`, CONSTRAINT `devices_owner_users_pk_fk` FOREIGN KEY (`owner`) REFERENCES `users` (`pk`))'
}

because of this not being implemented.