Follow-up from "Migrate merge requests mentions to DB table"
Summary
spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
spec is dependent on current app structure
The following discussion from !25826 (merged) should be addressed:
-
@pshutsin started a discussion: @acroitor @toon @smcgivern Using
becomes(User)
andbecomes(Namespace)
makes migration spec dependent on app code and current DB structure.See example failed pipeline where
user_type
column was introduced, There is nouser_type
column for this migration spec butUser
class requires it.I'll short-fix the spec for my local branch, and will create an issue to fix it properly.
Steps to reproduce
- Add new column to Users table. E.g.
add_column :users, :my_new_attr, null: false
- Add Rails-validation to new column
validates :my_new_attr, presence: true
- Run
bundle exec rspec spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
- => Spec will fail because
User
class will demandmy_new_attr
to be present, but there will be nomy_new_attr
because the spec is run against specific schema versionschema: 20200211155539
Implications
This spec has a change to fail every time there is a database OR validation changes to User
and Namespace
models.
@acroitor could you lead the fix please?