Prevent adding columns to wide tables
What does this MR do?
Prevents adding columns to wide tables by adding a new migration cop.
On GitLab.com, tables ordered by number of columns are:
gitlabhq_production=> SELECT table_name, COUNT(*) AS column_count FROM information_schema.columns WHERE table_schema='public' GROUP BY table_name ORDER BY column_count DESC LIMIT(10);
table_name | column_count
------------------------------------------+--------------
application_settings | 231
users | 85
projects | 82
geo_node_statuses | 54
ci_builds | 51
namespaces | 46
merge_requests | 39
conversational_development_index_metrics | 33
epics | 33
issues | 31
(10 rows)
Based on that information, I took 50
as a limit, meaning tables above 50
columns are considered wide tables. I didn't include application_settings
nor geo_node_statuses
as they barely have records, so I don't think it's necessary to blacklisted them:
gitlabhq_production=> select count(*) from application_settings;
count
-------
1
(1 row)
gitlabhq_production=> select count(*) from geo_node_statuses; count
-------
0
(1 row)
This new cop is only preventing adding columns to users
, projects
and ci_builds
. We can add more tables later if necessary.
Related to #201933 (closed)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Mayra Cabrera