Set organization_id when registering OAuth applications (19.0 backport)

What does this MR do and why?

Backport of !2984 (merged) to the 19.0 stable branch.

custom-instance-setup registers OAuth applications (Pages, Mattermost, etc.) on setup. This MR registers them through Authn::OauthApplication (the configured Doorkeeper application model) and passes organization_id: Organizations::Organization::DEFAULT_ORGANIZATION_ID on create. Existing applications found with a NULL organization_id are backfilled via update_column.

This fixes a PG::CheckViolation on the check_77eda6baaa constraint of the oauth_applications table, enforced by the add_not_null_constraint_to_oauth_applications_organization_id post-migration. OAuth applications registered during instance setup were inserted without an organization_id, causing the NOT NULL check constraint validation to fail during upgrades.

Counterpart of omnibus-gitlab!9548.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

  • This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
  • The original MR has been deployed to GitLab.com (not applicable for documentation or spec changes).
  • This MR has a severity label assigned (if applicable).

Note to the merge request author and maintainer

If you have questions about the patch release process, please:

🤖 Drafted by Claude Code.

Edited by Shilpa Kundapur

Merge request reports

Loading