-
- Downloads
There was an error fetching the commit references. Please try again later.
Add loose FK + model associations to vulnerability_occurrences cols
We want to drop the `vulnerability_occurrence_pipelines` table. In order to do this, we still need the first and latest pipeline ID stored somewhere to support the existing feature-set We added these columns, along with indexes, in previous commits. With that work done, we are now unblocked to add foreign keys and model associations, to prepare to actually backfill and use these columns Loose Foreign Keys ------------------------ As the pipelines table and the vulnerabilities table are in separate databases, we need to use [loose foreign keys][0]. As part of that process, I ran the script: ```sh scripts/decomposition/generate-loose-foreign-key -c vulnerability_occurrences ``` This generated specs that were not passing. To make these specs pass I needed to modify the factories from: ```ruby let_it_be(:model) { create(:vulnerability_occurrences, initial_pipeline: parent) } let_it_be(:model) { create(:vulnerability_occurrences, latest_pipeline: parent) } ``` to: ```ruby let_it_be(:model) { create(:vulnerabilities_finding, initial_pipeline_id: parent.id) } let_it_be(:model) { create(:vulnerabilities_finding, latest_pipeline_id: parent.id) } ``` [0]:https://docs.gitlab.com/ee/development/database/loose_foreign_keys.html related to: #422382 resolves: #443284 resolves: #443283 Changelog: changed
Showing
- config/gitlab_loose_foreign_keys.yml 7 additions, 0 deletionsconfig/gitlab_loose_foreign_keys.yml
- ee/app/models/vulnerabilities/finding.rb 5 additions, 0 deletionsee/app/models/vulnerabilities/finding.rb
- ee/spec/models/vulnerabilities/finding_spec.rb 15 additions, 1 deletionee/spec/models/vulnerabilities/finding_spec.rb
- spec/db/schema_spec.rb 0 additions, 1 deletionspec/db/schema_spec.rb
Please register or sign in to comment