Add functionality and feature flag to allow hard deleting organizations
Created by: miveronese
Ticket: https://sourcegraph.atlassian.net/browse/CLOUD-81
This PR adds the following:
- a new graphql mutation to allow hard deletion of organizations
- a new HardDelete method (in the OrgStore)
- unit tests
Test plan
Unit tests
Run the new tests with:
go test ./cmd/frontend/graphqlbackend/. -v -run TestRemoveOrganization
and
go test ./internal/database/. -run TestDeleteOrganization_OnPremise -v
go test ./internal/database/. -run TestDeleteOrganization_OnCloud -v
Manual test (via api/console)
-
Case one: you are in the DotCom mode but don't have the feature flag "org-deletion" enabled or it is set to false Run
sg start dotcom
Go to the /api/console Try to delete an organization by running the "removeOrganization" mutation You should see an error message informing that this operation is not supported -
Case two: you are in the DotCom mode and the feature flag "org-deletion" is set to true Run
sg start dotcom
Go to the /api/console Try to hard delete an organization by running the "removeOrganization" mutation All should work and the org will be hard deleted from the orgs table and from the associated tables -
Case three: you are not in the DotCom mode Run
sg start
Go to the /api/console Try to hard delete an organization You should see an error message informing that this operation is not supported
Queries
mutation CreateFeatureFlag{
createFeatureFlag(
name: "org-deletion",
value: false,
){
__typename
}
}
mutation {
removeOrganization(organization: "org-id") {
alwaysNil
}
}