Stop querying project_features when creating a Project object

[1] pry(main)> Project.new(id: 1)
  ActiveRecord::SchemaMigration Load (0.5ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  ActiveRecord::SchemaMigration Load (0.5ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  ProjectFeature Load (1.8ms)  SELECT  "project_features".* FROM "project_features" WHERE "project_features"."project_id" = $1 LIMIT 1  [["project_id", 1]]
  ActiveRecord::SchemaMigration Load (0.5ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  Route Load (2.4ms)  SELECT  "routes".* FROM "routes" WHERE "routes"."source_id" = $1 AND "routes"."source_type" = $2 LIMIT 1  [["source_id", 1], ["source_type", "Project"]]
=> #<Project id:1 gitlab-org/gitlab-test>

We shouldn't need the query against project_features there. It appears to come from the default_value_for :{issues,merge_requests,...}_enabled, which goes via ProjectFeaturesCompatibility:

def write_feature_attribute(field, value)
  build_project_feature unless project_feature

  # ...
end

This file says it's needed for API v3 compatibility. Now we're removing that API, could we also remove ProjectFeaturesCompatibility? Or, could we migrate existing rows somehow?

@fjsanpedro @felipe_artur wdyt?

Assignee Loading
Time tracking Loading