{"action":"closed","issue":{"url":"https://api.github.com/repos/OctopusDeploy/Issues/issues/4676","repository_url":"https://api.github.com/repos/OctopusDeploy/Issues","labels_url":"https://api.github.com/repos/OctopusDeploy/Issues/issues/4676/labels{/name}","comments_url":"https://api.github.com/repos/OctopusDeploy/Issues/issues/4676/comments","events_url":"https://api.github.com/repos/OctopusDeploy/Issues/issues/4676/events","html_url":"https://github.com/OctopusDeploy/Issues/issues/4676","id":335672479,"node_id":"MDU6SXNzdWUzMzU2NzI0Nzk=","number":4676,"title":"Update Release Variables orphans variable sets","user":{"login":"droyad","id":1687639,"node_id":"MDQ6VXNlcjE2ODc2Mzk=","avatar_url":"https://avatars0.githubusercontent.com/u/1687639?v=4","gravatar_id":"","url":"https://api.github.com/users/droyad","html_url":"https://github.com/droyad","followers_url":"https://api.github.com/users/droyad/followers","following_url":"https://api.github.com/users/droyad/following{/other_user}","gists_url":"https://api.github.com/users/droyad/gists{/gist_id}","starred_url":"https://api.github.com/users/droyad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droyad/subscriptions","organizations_url":"https://api.github.com/users/droyad/orgs","repos_url":"https://api.github.com/users/droyad/repos","events_url":"https://api.github.com/users/droyad/events{/privacy}","received_events_url":"https://api.github.com/users/droyad/received_events","type":"User","site_admin":false},"labels":[{"id":509292211,"node_id":"MDU6TGFiZWw1MDkyOTIyMTE=","url":"https://api.github.com/repos/OctopusDeploy/Issues/labels/area/modelling","name":"area/modelling","color":"006b75","default":false},{"id":62440875,"node_id":"MDU6TGFiZWw2MjQ0MDg3NQ==","url":"https://api.github.com/repos/OctopusDeploy/Issues/labels/kind/bug","name":"kind/bug","color":"eb6420","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-26T06:12:47Z","updated_at":"2018-06-26T06:18:12Z","closed_at":"2018-06-26T06:18:12Z","author_association":"NONE","body":"1. Create a library variable set\r\n1. Create a project\r\n1. Add a variable to that project\r\n1. Add the library variable set to the project\r\n1. Create a release\r\n1. Remove the variable and library variable set from the project\r\n1. Click `Update Variables` on release detail page\r\n\r\nThe project variable snapshot is now orphaned as it's no longer referenced by any releases. It should be deleted if no longer used (snapshots get deleted if the last released referencing them is deleted). This snapshot hanging around prevents accounts and other things being deleted and the user can't do anything about it\r\n\r\nQuery to find orphans:\r\n```\r\nSELECT * FROM VariableSet \r\nWHERE id not in (SELECT ProjectVariableSetSnapshotId from Release) \r\n    AND OwnerId like 'projects%' \r\n    AND IsFrozen = 1\r\n```\r\n\r\nAlso the library variable snapshot is now no longer in use and should be deleted (again if the release was actually deleted, it would have been removed). This prevents the library variable set from being deleted, as well as accounts, etc.\r\n\r\nQuery:\r\n\r\n```\r\nSELECT * FROM VariableSet \r\nWHERE not exists (SELECT * from Release WHERE json like '%' + VariableSet.Id + '%') \r\n    AND OwnerId like 'Library%' \r\n    AND IsFrozen = 1\r\n\r\n```\r\n\r\nFound this in testing another feature, but here is a User Report: https://secure.helpscout.net/conversation/605541234/28327/?folderId=557082\r\nhttps://help.octopus.com/t/cannot-delete-variableset/20413/8"}}
{"actor":{"display_login":"pawelpabich"}}