summaryrefslogtreecommitdiff
path: root/spec/db
diff options
context:
space:
mode:
Diffstat (limited to 'spec/db')
-rw-r--r--spec/db/schema_spec.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb
index 53f4a261092..e4eddb87858 100644
--- a/spec/db/schema_spec.rb
+++ b/spec/db/schema_spec.rb
@@ -120,9 +120,55 @@ describe 'Database schema' do
end
end
+ # These pre-existing enums have limits > 2 bytes
+ IGNORED_LIMIT_ENUMS = {
+ 'Analytics::CycleAnalytics::GroupStage' => %w[start_event_identifier end_event_identifier],
+ 'Analytics::CycleAnalytics::ProjectStage' => %w[start_event_identifier end_event_identifier],
+ 'Ci::Bridge' => %w[failure_reason],
+ 'Ci::Build' => %w[failure_reason],
+ 'Ci::BuildMetadata' => %w[timeout_source],
+ 'Ci::BuildTraceChunk' => %w[data_store],
+ 'Ci::JobArtifact' => %w[file_type],
+ 'Ci::Pipeline' => %w[source config_source failure_reason],
+ 'Ci::Runner' => %w[access_level],
+ 'Ci::Stage' => %w[status],
+ 'Clusters::Applications::Ingress' => %w[ingress_type],
+ 'Clusters::Cluster' => %w[platform_type provider_type],
+ 'CommitStatus' => %w[failure_reason],
+ 'GenericCommitStatus' => %w[failure_reason],
+ 'Gitlab::DatabaseImporters::CommonMetrics::PrometheusMetric' => %w[group],
+ 'InternalId' => %w[usage],
+ 'List' => %w[list_type],
+ 'NotificationSetting' => %w[level],
+ 'Project' => %w[auto_cancel_pending_pipelines],
+ 'ProjectAutoDevops' => %w[deploy_strategy],
+ 'PrometheusMetric' => %w[group],
+ 'ResourceLabelEvent' => %w[action],
+ 'User' => %w[layout dashboard project_view],
+ 'UserCallout' => %w[feature_name],
+ 'PrometheusAlert' => %w[operator]
+ }.freeze
+
+ context 'for enums' do
+ ApplicationRecord.descendants.each do |model|
+ describe model do
+ let(:ignored_enums) { ignored_limit_enums(model.name) }
+ let(:enums) { model.defined_enums.keys - ignored_enums }
+
+ it 'uses smallint for enums' do
+ expect(model).to use_smallint_for_enums(enums)
+ end
+ end
+ end
+ end
+
private
def ignored_fk_columns(column)
IGNORED_FK_COLUMNS.fetch(column, [])
end
+
+ def ignored_limit_enums(model)
+ IGNORED_LIMIT_ENUMS.fetch(model, [])
+ end
end