Add sharding keys to slack_integrations table
What does this MR do and why?
This MR creates columns to be used as sharding keys for the slack_integrations
table.
References
How to set up and validate locally
Setting up Slack
https://docs.gitlab.com/user/project/integrations/gitlab_slack_application/
- Created a free Slack workspace.
- Within that workspace, create an app: https://api.slack.com/apps/
- Enter the app details in your GDK admin panel: http://gdk.test:3000/admin/application_settings/general
- Under http://gdk.test:3000/admin/application_settings/integrations, enable the GitLab for Slack app
- Click "Allow" when prompted on Slack. You should be successfully redirected back to your GDK.
Checking ID propagation
- After installing the Slack app at the instance level, you should have an instance level integration, and one for each project and group.
Group.count + Project.count + 1 == SlackIntegration.count
# => true
- The sharding key of each integration SHOULD correspond to the organization ID (for the instance level integration) or the project/group to which it belongs.
SlackIntegration.pluck(:id, :organization_id, :group_id, :project_id)
correct_values = SlackIntegration.all.all? do |integration|
expected_alias = if integration.organization_id
"_gitlab-instance"
elsif integration.group_id
Group.find(integration.group_id).full_path
elsif integration.project_id
Project.find(integration.project_id).full_path
end
integration.alias == expected_alias
end
if correct_values
puts "✅ All sharding keys correspond to the expected alias"
else
puts "💣 Mismatch between sharding key and alias"
end
- Manually create a group and a project. The last two
SlackIntegration
records should have the correct sharding key set, verifiable with the above script.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by James Nutt