Unable to delete a tenant that has users
Closed this issue · 1 comments
johnmaia commented
I'm currently using the @fusionauth/node-client
version 1.7.3
and I'm unable to delete a tenant
that has registered users.
When I call the following error is thrown when the deleteTenant
method is called:
{
statusCode: 500,
errorResponse: {
generalErrors: [{
code: '[Exception]',
message: 'FusionAuth encountered an unexpected error. Please contact support for assistance.'
}]
},
successResponse: null,
exception: null
}
For more details I've took a look at the database
(postgres-10.6) and fusionauth-app
(1.7.2) docker services logs:
database_1 | 2019-07-15 12:43:41.371 UTC [36] ERROR: update or delete on table "tenants" violates foreign key constraint "users_fk_1" on table "users"
database_1 | 2019-07-15 12:43:41.371 UTC [36] DETAIL: Key (id)=(0bf426e2-1a50-4291-9915-e70b5ebe3621) is still referenced from table "users".
database_1 | 2019-07-15 12:43:41.371 UTC [36] STATEMENT: DELETE FROM tenants WHERE id = $1
fusionauth_1 | Jul 15, 2019 12:43:41.376 PM ERROR io.fusionauth.app.primeframework.error.ExceptionExceptionHandler - An unhandled exception was thrown
fusionauth_1 | org.apache.ibatis.exceptions.PersistenceException:
fusionauth_1 | ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "tenants" violates foreign key constraint "users_fk_1" on table "users"
fusionauth_1 | Detail: Key (id)=(0bf426e2-1a50-4291-9915-e70b5ebe3621) is still referenced from table "users".
fusionauth_1 | ### The error may involve defaultParameterMap
fusionauth_1 | ### The error occurred while setting parameters
fusionauth_1 | ### SQL: DELETE FROM tenants WHERE id = ?
fusionauth_1 | ### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "tenants" violates foreign key constraint "users_fk_1" on table "users"
fusionauth_1 | Detail: Key (id)=(0bf426e2-1a50-4291-9915-e70b5ebe3621) is still referenced from table "users".
fusionauth_1 | at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
fusionauth_1 | at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
fusionauth_1 | at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:213)
fusionauth_1 | at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
...
Please note that deleting the tenant via dashboard works flawlessly.
johnmaia commented
Moved the issue to the correct repo. FusionAuth/fusionauth-issues#221