Check for enums not using smallint
What does this MR do?
This MR adds a schema test to check that any new enum introduced has the type of smallint
. In schema.rb
, this is indicated by limit: 2
in the column definition.
Closes #25012 (closed)
Screenshots
Example spec failure:
Failures:
1) Database schema for enums User uses smallint for enums
Failure/Error: expect(model).to use_smallint_for_enums(enums)
Expected User enums: layout, dashboard, project_view to use the smallint type.
The smallint type is 2 bytes which is more than sufficient for an enum.
Using the smallint type would help us save space in the database.
To fix this, please add `limit: 2` in the migration file, for example:
def change
add_column :ci_job_artifacts, :file_format, :integer, limit: 2
end
# ./spec/db/schema_spec.rb:157:in `block (5 levels) in <top (required)>'
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation created/updated or follow-up review issue created
- [-] Code review guidelines
- [-] Merge request performance guidelines
- [-] Style guides
-
Database guides -
Separation of EE specific content
Performance and Testing
Edited by Albert Salim