From f40b5860d76a8ea5d964260834a6e83516b0f1fd Mon Sep 17 00:00:00 2001 From: Reuben Pereira Date: Mon, 7 Jan 2019 17:55:21 +0000 Subject: Add table and model for error tracking settings --- spec/db/schema_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'spec/db') diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb index 7c505ee0d43..897b4411055 100644 --- a/spec/db/schema_spec.rb +++ b/spec/db/schema_spec.rb @@ -64,6 +64,7 @@ describe 'Database schema' do let(:indexes) { connection.indexes(table) } let(:columns) { connection.columns(table) } let(:foreign_keys) { connection.foreign_keys(table) } + let(:primary_key_column) { connection.primary_key(table) } context 'all foreign keys' do # for index to be effective, the FK constraint has to be at first place @@ -71,6 +72,12 @@ describe 'Database schema' do first_indexed_column = indexes.map(&:columns).map(&:first) foreign_keys_columns = foreign_keys.map(&:column) + # Add the primary key column to the list of indexed columns because + # postgres and mysql both automatically create an index on the primary + # key. Also, the rails connection.indexes() method does not return + # automatically generated indexes (like the primary key index). + first_indexed_column = first_indexed_column.push(primary_key_column) + expect(first_indexed_column.uniq).to include(*foreign_keys_columns) end end -- cgit v1.2.1