Skip to content

Set PersonalSnippet organization_id

Hunter Stewart requested to merge hustewart-set-org-id into master

Why

Issue: Fill `organization_id` during PersonalSnippets ... (#460827 - closed)

Epic: Update Snippets table to support Cells 1.0 (&13636)

Comment that explains nullifcation/id setting approach: #458098 (comment 1897314738)

We added the new organization_id column to snippets with a default value of 1.

Now, for PersonalSnippets, we want to use the user's currently selected organization to populate the value during creation.

What

  • Set PersonalSnippet organization_id

This MR uses the Current.organization_id to attempt to set the value on PersonalSnippets in their create service. If no value is returned, the default value of 1 is used.

Follow up

We can clean up this service with a refactor: Handle Snippet types in Create::Snippet service (#469564)

Other files that should get cleaned up have been added to the issue as well.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  • create a new, non project snippet

  • verify it gets the default value of snippet.organization_id == 1 (this is the case we can't select another org, so the default value kicks in)

  • create a project snippet

  • verify it gets snippet.organization_id == nil

We can't switch organizations yet so I'm not sure how to locally validate that if you switched organizations you'd get the new organization's id.

If reviewer's have ideas of how we can achieve this in local validation, please update this description.

Edited by Hunter Stewart

Merge request reports