Ensure new Releases always have `author_id`
What does this MR do and why?
Add validation on author_id
for new release
records.
Also fixes the Github importer and legacy Github importer which were importing releases without author_id
.
Records created before %11.7 will continue to have empty author_id. We are performing backfil DB migration because of reasons listed out in #343448 (comment 965640386)
- legacy reason 1ea2d9fa
- Foreign key relation with User table i.e
fk_8e4456f90f
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Rails console
> Feature.enable(:validate_release_with_author)
> release = Release.new(project: Project.last, author_id: nil, name: 'Release 1.0', tag: 'V1.0')
> release.save!
ActiveRecord::RecordInvalid: Validation failed: Author can't be blank
from /Users/bala/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/activerecord-6.1.4.7/lib/active_record/validations.rb:80:in `raise_validation_error'
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #343448 (closed)
Edited by Bala Kumar