summaryrefslogtreecommitdiff
path: root/spec/db/schema_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/db/schema_spec.rb')
-rw-r--r--spec/db/schema_spec.rb48
1 files changed, 47 insertions, 1 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb
index 53f4a261092..e8b30868801 100644
--- a/spec/db/schema_spec.rb
+++ b/spec/db/schema_spec.rb
@@ -13,7 +13,7 @@ describe 'Database schema' do
# EE: edit the ee/spec/db/schema_support.rb
IGNORED_FK_COLUMNS = {
abuse_reports: %w[reporter_id user_id],
- application_settings: %w[performance_bar_allowed_group_id slack_app_id snowplow_site_id],
+ application_settings: %w[performance_bar_allowed_group_id slack_app_id snowplow_app_id eks_account_id eks_access_key_id],
approvers: %w[target_id user_id],
approvals: %w[user_id],
approver_groups: %w[target_id],
@@ -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