Add organization_id to the web_hooks table
Implementation Plan
-
Add an organization_idcolumn to theweb_hookstable- Do not add a default value, as the intention is to only have the
organization_idset for records which are organization wide.
- Do not add a default value, as the intention is to only have the
-
Add belongs_to :organizationto the WebHook model, along with any necessary validations or callbacks. Set theorganization_idtoOrganization.currentwhen creating newSystemHookand system wideServiceHookrecords. -
Create a post migration to set the organization_idto::Organizations::Organization.first.idfor all system hooks whereorganization_idisnil -
Add sharding key on new records for ServiceHook -
Create backgroundpost migration to add eitherproject_idgroup_idororganization_idtoServiceHooktype webhooks -
Create a multi column not null check so each hook has exactly 1 of organization_id,project_idorgroup_id, and set these as the sharding keys. Addvalidates :organization_id, presence: truetoapp/models/hooks/system_hook.rb -
remove web_hookstable fromwork_in_progressinspec/lib/gitlab/database/sharding_key_spec.rb
Edited by Carla Drago