Skip to content

Add functionality and feature flag to allow hard deleting organizations

Administrator requested to merge mv/org-deletion into main

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)

  1. 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

  2. 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

  3. 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

  }
}

Merge request reports

Loading