Add visibility column to ai_catalog_items
What does this MR do and why?
This MR adds a visibility column to the ai_catalog_items table. The plan is to use this as the primary visibility column and deprecate the public column.
In this MR, we're adding the visibility column with Rails enum values and backfilling it from the public column. At the model level, we're adding a callback to keep the visibility column in sync with public.
References
How to set up and validate locally
- Check out this branch and run migration
- Once migration executed, open the rails console and run below.
Ai::Catalog::Item.where(public: false).pluck(:visibility).uniq # Must be ["private"]
Ai::Catalog::Item.where(public: true).pluck(:visibility).uniq # Must be ["public"]- Update on any item, it should also update the visibility column value.
item = Ai::Catalog::Item.last
item.public = false
item.save
item.visibility # private
item.public = true
item.save
item.visibility # publicDatabase review
Table ai_catalog_items is having ~10.6k records at the moment. See plan - https://console.postgres.ai/gitlab/gitlab-production-main/sessions/53023/commands/154716
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 #602935 (closed)