Skip to content

Add organization_id to the web_hooks table

Implementation Plan

  • Add an organization_id column to the web_hooks table
    • Do not add a default value, as the intention is to only have the organization_id set for records which are organization wide.
  • Add belongs_to :organization to the WebHook model, along with any necessary validations or callbacks. Set the organization_id to Organization.current when creating new SystemHook and system wide ServiceHook records.
  • Create a post migration (or 2) to set the organization_id to ::Organizations::Organization.first.id for all system hooks where organization_id is nil
  • Create a multi column not null check so each hook has exactly 1 of organization_id, project_id or group_id, and set these as the sharding keys. Add validates :organization_id, presence: true to app/models/hooks/system_hook.rb
  • remove web_hooks table from work_in_progress in spec/lib/gitlab/database/sharding_key_spec.rb
  • create issue to finalize the background migration
Edited by Carla Drago