Create cop for FactoryBot methods used in migration specs
Using a factory method (like create
or build
) in a migration spec (which uses a particular schema version) can be problematic for a couple of reasons:
- The column information on any models used by the factory will be cached to the schema version used by the migration spec, so later specs using the same model will have an outdated schema cache: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16487
- If we add a field to the factory after the migration spec is written, the migration spec will fail when it tries to assign that field, because we will be using an older schema.