Update Active Context Collections table

What does this MR do and why?

Updates the Ai::ActiveContext::Collection table according to !180558 (comment 2353514461):

  1. [Migration] Adds a foreign key to Ai::ActiveContext::Connection
  2. [Post deployment migration] Adds a unique index on connection_id and name to prevent duplicate names per connection

Table definition after the migrations:

Screenshot_2025-02-20_at_15.11.15

NOTE: this table definitely does not contain any records on .com or SM so we don't need to worry about having duplicate names.

Screenshot_2025-02-18_at_15.17.08

https://docs.gitlab.com/development/database/adding_database_indexes/#add-a-unique-index-acting-as-a-constraint-to-an-existing-table

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

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.

How to set up and validate locally

  1. Run migrations: ./scripts/database/migrate.rb -t up
  2. Create a collection record in a rails console
  3. Revert migrations: ./scripts/database/migrate.rb -t down
Edited by Madelein van Niekerk

Merge request reports

Loading