Skip to content

Start writing to new columns in packages_protection_rules

🛠️ What does this MR do and why?

In the previous MR, we added new columns that required for supporting new target_field and pattern_type.

Before we backfill the null columns, we need to start writing those fields to avoid having empty columns and then we can add not-null constraint in the future.

This MR starts to write to pattern_type, pattern and target_field when user create or update protection rules via UI.

References

N/A

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Stay in master branch, go to project package and registries page (http://gdk.test:3000/gitlab-org/gitlab-test/-/settings/packages_and_registries) to create a new rule
  2. Enter rails console, check pattern field of the record is null. (target_field and pattern_type have default value, so it won't be null)
    rule1 = Packages::Protection::Rule.last
  3. Switch to this branch 569936-writing-to-new-columns-in-packages-protection-rules
  4. Back to UI, create a new protection rule
  5. Enter rails console, , check pattern field of the record is the same as package_name_pattern
  6. For update, you can update the rule that created in step 2, after updated, go to step 5 and check the record is updated as expected.

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.

Related to #569936 (closed)

Merge request reports

Loading