active_record_doctor 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 926da2f13aede9586aa602b38ea667daf6d4bca8
4
- data.tar.gz: aa2b11cd9aa3d699603d58de3ea9f19d1cfb206a
3
+ metadata.gz: b34a82d16d09817af606ea87f37d3fd58ed4d90c
4
+ data.tar.gz: 295e95a5bd798fb32fb601b323e534ce1f8d99a7
5
5
  SHA512:
6
- metadata.gz: 6451ee2261ccb85fe288cdcb7c747bfa4ee5de94262c04f11ea3d64c4aeefe5023b4e508d076434e8879a73bd702c1a392b37f0f21d4d5f58e464f9948397559
7
- data.tar.gz: b72600d9d2d0801d66c09004464290335080a3bd2891c0bb8d4d243fb64649070c5167212b56a0462ff91697527e3f30e80ddbd9029bfe1b645c6ea87ae587fc
6
+ metadata.gz: 91e990085d0d24165b8ed2c2ffed14e012b903fad6d20239822fb737ba64b117956dc39222be5818cef6bec23ef765eeee8d5d9c37399a52296464a6a27af477
7
+ data.tar.gz: dc076f6c5526717552dca94594d845cbfc105c19d305c38f1dba1442a0d48e5a28197efaabf4cb8d3be259ecf5e5822c337833aa097c899a4c15076866038d45
data/README.md CHANGED
@@ -6,6 +6,7 @@ can:
6
6
  * index unindexed foreign keys
7
7
  * detect extraneous indexes
8
8
  * detect missing foreign key constraints
9
+ * detect models referencing undefined tables
9
10
 
10
11
  More features coming soon!
11
12
 
@@ -140,6 +141,30 @@ class AddForeignKeyConstraintToUsersProfileId < ActiveRecord::Migration
140
141
  end
141
142
  ```
142
143
 
144
+ ### Detecting Models Referencing Undefined Tables
145
+
146
+ Active Record guesses the table name based on the class name. There are a few
147
+ cases where the name can be wrong (e.g. you forgot to commit a migration or
148
+ changed the table name). Active Record Doctor can help you identify these cases
149
+ before they hit production.
150
+
151
+ The only think you need to do is run:
152
+
153
+ ```
154
+ rake active_record_doctor:undefined_table_references
155
+ ```
156
+
157
+ If there a model references an undefined table then you'll see a message like
158
+ this:
159
+
160
+ ```
161
+ The following models reference undefined tables:
162
+ Contract (the table contract_records is undefined)
163
+ ```
164
+
165
+ On top of that `rake` will exit with status code of 1. This allows you to use
166
+ this check as part of your Continuous Integration pipeline.
167
+
143
168
  ## Author
144
169
 
145
170
  This gem is developed and maintained by [Greg Navis](http://www.gregnavis.com).
@@ -35,6 +35,15 @@ module ActiveRecordDoctor
35
35
  "#{table} #{columns.sort.join(' ')}"
36
36
  end.join("\n"))
37
37
  end
38
+
39
+ def print_undefined_table_references(models)
40
+ return if models.empty?
41
+
42
+ @io.puts('The following models reference undefined tables:')
43
+ models.each do |model|
44
+ @io.puts(" #{model.name} (the table #{model.table_name} is undefined)")
45
+ end
46
+ end
38
47
  end
39
48
  end
40
49
  end
@@ -0,0 +1,33 @@
1
+ require "active_record_doctor/compatibility"
2
+ require "active_record_doctor/printers/io_printer"
3
+
4
+ module ActiveRecordDoctor
5
+ module Tasks
6
+ class UndefinedTableReferences
7
+ include Compatibility
8
+
9
+ def self.run
10
+ new.run
11
+ end
12
+
13
+ def initialize(printer: ActiveRecordDoctor::Printers::IOPrinter.new)
14
+ @printer = printer
15
+ end
16
+
17
+ def run
18
+ @printer.print_undefined_table_references(undefined_table_references)
19
+ undefined_table_references.present? ? 1 : 0
20
+ end
21
+
22
+ private
23
+
24
+ def undefined_table_references
25
+ Rails.application.eager_load!
26
+
27
+ ActiveRecord::Base.subclasses.reject do |model|
28
+ model.connection.tables.include?(model.table_name)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordDoctor
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "active_record_doctor/tasks/unindexed_foreign_keys"
2
2
  require "active_record_doctor/tasks/extraneous_indexes"
3
3
  require "active_record_doctor/tasks/missing_foreign_keys"
4
+ require "active_record_doctor/tasks/undefined_table_references"
4
5
 
5
6
  namespace :active_record_doctor do
6
7
  task :unindexed_foreign_keys => :environment do
@@ -14,4 +15,8 @@ namespace :active_record_doctor do
14
15
  task :missing_foreign_keys => :environment do
15
16
  ActiveRecordDoctor::Tasks::MissingForeignKeys.run
16
17
  end
18
+
19
+ task :undefined_table_references => :environment do
20
+ exit(ActiveRecordDoctor::Tasks::UndefinedTableReferences.run)
21
+ end
17
22
  end
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+
3
+ require 'active_record_doctor/tasks/undefined_table_references'
4
+
5
+ class ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest < ActiveSupport::TestCase
6
+ def test_undefined_table_references_are_reported
7
+ result = run_task
8
+
9
+ assert_equal([Contract], result)
10
+ end
11
+
12
+ private
13
+
14
+ def run_task
15
+ printer = SpyPrinter.new
16
+ ActiveRecordDoctor::Tasks::UndefinedTableReferences.new(printer: printer).run
17
+ printer.undefined_table_references
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ class Contract < ActiveRecord::Base
2
+ self.table_name = 'contract_records'
3
+ end
@@ -83,3 +83,54 @@ WHERE c.contype = 'f'
83
83
  AND t3.nspname = ANY (current_schemas(false))
84
84
  ORDER BY c.conname
85
85
 
86
+ SQL (0.1ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
87
+  (31.0ms) CREATE TABLE "comments" ("id" serial primary key, "commentable_id" integer, "commentable_type" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
88
+  (17.6ms) CREATE INDEX "index_comments_on_commentable_type_and_commentable_id" ON "comments" USING btree ("commentable_type", "commentable_id")
89
+  (34.4ms) CREATE TABLE "employers" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
90
+  (12.9ms) CREATE INDEX "index_employers_on_id" ON "employers" USING btree ("id")
91
+  (31.9ms) CREATE TABLE "profiles" ("id" serial primary key, "first_name" character varying, "last_name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
92
+  (35.7ms) CREATE TABLE "users" ("id" serial primary key, "email" character varying, "first_name" character varying, "last_name" character varying, "profile_id" integer, "employer_id" integer, "country_code" character varying NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
93
+  (18.0ms) CREATE INDEX "index_users_on_email" ON "users" USING btree ("email")
94
+  (18.2ms) CREATE UNIQUE INDEX "unique_index_on_users_email" ON "users" USING btree ("email")
95
+  (18.2ms) CREATE INDEX "index_users_on_employer_id_and_country_code" ON "users" USING btree ("employer_id", "country_code")
96
+  (12.9ms) CREATE INDEX "index_users_on_last_name_and_first_name_and_email" ON "users" USING btree ("last_name", "first_name", "email")
97
+  (23.8ms) CREATE INDEX "index_users_on_last_name_and_first_name" ON "users" USING btree ("last_name", "first_name")
98
+  (21.1ms) CREATE UNIQUE INDEX "unique_index_on_users_last_name_and_first_name" ON "users" USING btree ("last_name", "first_name")
99
+  (24.6ms) CREATE INDEX "index_users_on_last_name" ON "users" USING btree ("last_name")
100
+  (9.2ms) ALTER TABLE "users" ADD CONSTRAINT "fk_rails_e0dbdd604c"
101
+ FOREIGN KEY ("employer_id")
102
+ REFERENCES "employers" ("id")
103
+ 
104
+  (26.4ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
105
+  (26.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
106
+  (0.3ms) SELECT version FROM "schema_migrations"
107
+  (2.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20160604081452')
108
+  (7.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20160213101213')
109
+  (7.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20160213101232')
110
+  (2.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20160213101221')
111
+ SQL (0.1ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
112
+  (57.5ms) CREATE TABLE "comments" ("id" serial primary key, "commentable_id" integer, "commentable_type" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
113
+  (20.9ms) CREATE INDEX "index_comments_on_commentable_type_and_commentable_id" ON "comments" USING btree ("commentable_type", "commentable_id")
114
+  (46.0ms) CREATE TABLE "employers" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
115
+  (12.2ms) CREATE INDEX "index_employers_on_id" ON "employers" USING btree ("id")
116
+  (29.4ms) CREATE TABLE "profiles" ("id" serial primary key, "first_name" character varying, "last_name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
117
+  (32.3ms) CREATE TABLE "users" ("id" serial primary key, "email" character varying, "first_name" character varying, "last_name" character varying, "profile_id" integer, "employer_id" integer, "country_code" character varying NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
118
+  (17.2ms) CREATE INDEX "index_users_on_email" ON "users" USING btree ("email")
119
+  (14.7ms) CREATE UNIQUE INDEX "unique_index_on_users_email" ON "users" USING btree ("email")
120
+  (22.9ms) CREATE INDEX "index_users_on_employer_id_and_country_code" ON "users" USING btree ("employer_id", "country_code")
121
+  (17.8ms) CREATE INDEX "index_users_on_last_name_and_first_name_and_email" ON "users" USING btree ("last_name", "first_name", "email")
122
+  (17.3ms) CREATE INDEX "index_users_on_last_name_and_first_name" ON "users" USING btree ("last_name", "first_name")
123
+  (22.9ms) CREATE UNIQUE INDEX "unique_index_on_users_last_name_and_first_name" ON "users" USING btree ("last_name", "first_name")
124
+  (11.8ms) CREATE INDEX "index_users_on_last_name" ON "users" USING btree ("last_name")
125
+  (8.5ms) ALTER TABLE "users" ADD CONSTRAINT "fk_rails_e0dbdd604c"
126
+ FOREIGN KEY ("employer_id")
127
+ REFERENCES "employers" ("id")
128
+ 
129
+  (21.3ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
130
+  (20.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
131
+  (0.2ms) SELECT version FROM "schema_migrations"
132
+  (4.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20160604081452')
133
+  (7.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20160213101213')
134
+  (7.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20160213101232')
135
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20160213101221')
136
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -139,3 +139,690 @@ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_re
139
139
  ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
140
140
  ---------------------------------------------------------------------------------------------
141
141
   (0.0ms) ROLLBACK
142
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
143
+  (0.1ms) BEGIN
144
+ ----------------------------------------------------------------------------------
145
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
146
+ ----------------------------------------------------------------------------------
147
+  (0.1ms) ROLLBACK
148
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
149
+  (0.1ms) BEGIN
150
+ ----------------------------------------------------------------------------------
151
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
152
+ ----------------------------------------------------------------------------------
153
+  (0.1ms) ROLLBACK
154
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
155
+  (0.1ms) BEGIN
156
+ ----------------------------------------------------------------------------------
157
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
158
+ ----------------------------------------------------------------------------------
159
+  (0.2ms) ROLLBACK
160
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
161
+  (0.2ms) BEGIN
162
+ ----------------------------------------------------------------------------------
163
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
164
+ ----------------------------------------------------------------------------------
165
+  (0.1ms) ROLLBACK
166
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
167
+  (0.2ms) BEGIN
168
+ ----------------------------------------------------------------------------------
169
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
170
+ ----------------------------------------------------------------------------------
171
+  (0.1ms) ROLLBACK
172
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
173
+  (0.1ms) BEGIN
174
+ ----------------------------------------------------------------------------------
175
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
176
+ ----------------------------------------------------------------------------------
177
+  (0.1ms) ROLLBACK
178
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
179
+  (0.1ms) BEGIN
180
+ ----------------------------------------------------------------------------------
181
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
182
+ ----------------------------------------------------------------------------------
183
+  (0.2ms) ROLLBACK
184
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
185
+  (0.1ms) BEGIN
186
+ ----------------------------------------------------------------------------------
187
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
188
+ ----------------------------------------------------------------------------------
189
+  (0.1ms) ROLLBACK
190
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
191
+  (0.1ms) BEGIN
192
+ ----------------------------------------------------------------------------------
193
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
194
+ ----------------------------------------------------------------------------------
195
+  (0.1ms) ROLLBACK
196
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
197
+  (0.1ms) BEGIN
198
+ ----------------------------------------------------------------------------------
199
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
200
+ ----------------------------------------------------------------------------------
201
+  (0.1ms) ROLLBACK
202
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
203
+  (0.2ms) BEGIN
204
+ ----------------------------------------------------------------------------------
205
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
206
+ ----------------------------------------------------------------------------------
207
+  (0.1ms) ROLLBACK
208
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
209
+  (0.1ms) BEGIN
210
+ ---------------------------------------------------------------------------------------------
211
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
212
+ ---------------------------------------------------------------------------------------------
213
+  (0.0ms) ROLLBACK
214
+  (0.0ms) BEGIN
215
+ ----------------------------------------------------------------------------------
216
+ ActiveRecordDoctor::Tasks::UndefinedTablesTest: test_undefined_tables_are_reported
217
+ ----------------------------------------------------------------------------------
218
+  (0.1ms) ROLLBACK
219
+  (0.0ms) BEGIN
220
+ --------------------------------------------------------------------------------------
221
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
222
+ --------------------------------------------------------------------------------------
223
+  (0.0ms) ROLLBACK
224
+  (0.0ms) BEGIN
225
+ ------------------------------------------------------------------------------
226
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
227
+ ------------------------------------------------------------------------------
228
+  (0.1ms) ROLLBACK
229
+  (0.0ms) BEGIN
230
+ -----------------------------------------------------------------------------------------
231
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
232
+ -----------------------------------------------------------------------------------------
233
+  (1.6ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
234
+ FROM pg_constraint c
235
+ JOIN pg_class t1 ON c.conrelid = t1.oid
236
+ JOIN pg_class t2 ON c.confrelid = t2.oid
237
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
238
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
239
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
240
+ WHERE c.contype = 'f'
241
+ AND t1.relname = 'comments'
242
+ AND t3.nspname = ANY (current_schemas(false))
243
+ ORDER BY c.conname
244
+ 
245
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
246
+ FROM pg_constraint c
247
+ JOIN pg_class t1 ON c.conrelid = t1.oid
248
+ JOIN pg_class t2 ON c.confrelid = t2.oid
249
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
250
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
251
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
252
+ WHERE c.contype = 'f'
253
+ AND t1.relname = 'users'
254
+ AND t3.nspname = ANY (current_schemas(false))
255
+ ORDER BY c.conname
256
+
257
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
258
+ FROM pg_constraint c
259
+ JOIN pg_class t1 ON c.conrelid = t1.oid
260
+ JOIN pg_class t2 ON c.confrelid = t2.oid
261
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
262
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
263
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
264
+ WHERE c.contype = 'f'
265
+ AND t1.relname = 'users'
266
+ AND t3.nspname = ANY (current_schemas(false))
267
+ ORDER BY c.conname
268
+ 
269
+  (0.1ms) ROLLBACK
270
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
271
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
272
+  (0.1ms) BEGIN
273
+ -----------------------------------------------------------------------------------------
274
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
275
+ -----------------------------------------------------------------------------------------
276
+  (1.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
277
+ FROM pg_constraint c
278
+ JOIN pg_class t1 ON c.conrelid = t1.oid
279
+ JOIN pg_class t2 ON c.confrelid = t2.oid
280
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
281
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
282
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
283
+ WHERE c.contype = 'f'
284
+ AND t1.relname = 'comments'
285
+ AND t3.nspname = ANY (current_schemas(false))
286
+ ORDER BY c.conname
287
+ 
288
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
289
+ FROM pg_constraint c
290
+ JOIN pg_class t1 ON c.conrelid = t1.oid
291
+ JOIN pg_class t2 ON c.confrelid = t2.oid
292
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
293
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
294
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
295
+ WHERE c.contype = 'f'
296
+ AND t1.relname = 'users'
297
+ AND t3.nspname = ANY (current_schemas(false))
298
+ ORDER BY c.conname
299
+
300
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
301
+ FROM pg_constraint c
302
+ JOIN pg_class t1 ON c.conrelid = t1.oid
303
+ JOIN pg_class t2 ON c.confrelid = t2.oid
304
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
305
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
306
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
307
+ WHERE c.contype = 'f'
308
+ AND t1.relname = 'users'
309
+ AND t3.nspname = ANY (current_schemas(false))
310
+ ORDER BY c.conname
311
+ 
312
+  (0.1ms) ROLLBACK
313
+  (0.0ms) BEGIN
314
+ ------------------------------------------------------------------------------
315
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
316
+ ------------------------------------------------------------------------------
317
+  (0.0ms) ROLLBACK
318
+  (0.0ms) BEGIN
319
+ -----------------------------------------------------------------------------------------------------
320
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
321
+ -----------------------------------------------------------------------------------------------------
322
+  (0.1ms) ROLLBACK
323
+  (0.0ms) BEGIN
324
+ --------------------------------------------------------------------------------------
325
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
326
+ --------------------------------------------------------------------------------------
327
+  (0.0ms) ROLLBACK
328
+  (0.0ms) BEGIN
329
+ ---------------------------------------------------------------------------------------------
330
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
331
+ ---------------------------------------------------------------------------------------------
332
+  (0.1ms) ROLLBACK
333
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
334
+  (0.1ms) BEGIN
335
+ ------------------------------------------------------------------------------
336
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
337
+ ------------------------------------------------------------------------------
338
+  (0.1ms) ROLLBACK
339
+  (0.1ms) BEGIN
340
+ -----------------------------------------------------------------------------------------------------
341
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
342
+ -----------------------------------------------------------------------------------------------------
343
+  (0.1ms) ROLLBACK
344
+  (0.1ms) BEGIN
345
+ --------------------------------------------------------------------------------------
346
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
347
+ --------------------------------------------------------------------------------------
348
+  (0.0ms) ROLLBACK
349
+  (0.0ms) BEGIN
350
+ -----------------------------------------------------------------------------------------
351
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
352
+ -----------------------------------------------------------------------------------------
353
+  (1.3ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
354
+ FROM pg_constraint c
355
+ JOIN pg_class t1 ON c.conrelid = t1.oid
356
+ JOIN pg_class t2 ON c.confrelid = t2.oid
357
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
358
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
359
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
360
+ WHERE c.contype = 'f'
361
+ AND t1.relname = 'comments'
362
+ AND t3.nspname = ANY (current_schemas(false))
363
+ ORDER BY c.conname
364
+ 
365
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
366
+ FROM pg_constraint c
367
+ JOIN pg_class t1 ON c.conrelid = t1.oid
368
+ JOIN pg_class t2 ON c.confrelid = t2.oid
369
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
370
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
371
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
372
+ WHERE c.contype = 'f'
373
+ AND t1.relname = 'users'
374
+ AND t3.nspname = ANY (current_schemas(false))
375
+ ORDER BY c.conname
376
+
377
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
378
+ FROM pg_constraint c
379
+ JOIN pg_class t1 ON c.conrelid = t1.oid
380
+ JOIN pg_class t2 ON c.confrelid = t2.oid
381
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
382
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
383
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
384
+ WHERE c.contype = 'f'
385
+ AND t1.relname = 'users'
386
+ AND t3.nspname = ANY (current_schemas(false))
387
+ ORDER BY c.conname
388
+ 
389
+  (0.2ms) ROLLBACK
390
+  (0.1ms) BEGIN
391
+ ---------------------------------------------------------------------------------------------
392
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
393
+ ---------------------------------------------------------------------------------------------
394
+  (0.0ms) ROLLBACK
395
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
396
+  (0.1ms) BEGIN
397
+ ------------------------------------------------------------------------------
398
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
399
+ ------------------------------------------------------------------------------
400
+  (0.1ms) ROLLBACK
401
+  (0.0ms) BEGIN
402
+ -----------------------------------------------------------------------------------------
403
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
404
+ -----------------------------------------------------------------------------------------
405
+  (1.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
406
+ FROM pg_constraint c
407
+ JOIN pg_class t1 ON c.conrelid = t1.oid
408
+ JOIN pg_class t2 ON c.confrelid = t2.oid
409
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
410
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
411
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
412
+ WHERE c.contype = 'f'
413
+ AND t1.relname = 'comments'
414
+ AND t3.nspname = ANY (current_schemas(false))
415
+ ORDER BY c.conname
416
+ 
417
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
418
+ FROM pg_constraint c
419
+ JOIN pg_class t1 ON c.conrelid = t1.oid
420
+ JOIN pg_class t2 ON c.confrelid = t2.oid
421
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
422
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
423
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
424
+ WHERE c.contype = 'f'
425
+ AND t1.relname = 'users'
426
+ AND t3.nspname = ANY (current_schemas(false))
427
+ ORDER BY c.conname
428
+
429
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
430
+ FROM pg_constraint c
431
+ JOIN pg_class t1 ON c.conrelid = t1.oid
432
+ JOIN pg_class t2 ON c.confrelid = t2.oid
433
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
434
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
435
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
436
+ WHERE c.contype = 'f'
437
+ AND t1.relname = 'users'
438
+ AND t3.nspname = ANY (current_schemas(false))
439
+ ORDER BY c.conname
440
+ 
441
+  (0.1ms) ROLLBACK
442
+  (0.0ms) BEGIN
443
+ -----------------------------------------------------------------------------------------------------
444
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
445
+ -----------------------------------------------------------------------------------------------------
446
+  (0.0ms) ROLLBACK
447
+  (0.0ms) BEGIN
448
+ ---------------------------------------------------------------------------------------------
449
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
450
+ ---------------------------------------------------------------------------------------------
451
+  (0.0ms) ROLLBACK
452
+  (0.0ms) BEGIN
453
+ --------------------------------------------------------------------------------------
454
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
455
+ --------------------------------------------------------------------------------------
456
+  (0.0ms) ROLLBACK
457
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
458
+  (0.2ms) BEGIN
459
+ ---------------------------------------------------------------------------------------------
460
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
461
+ ---------------------------------------------------------------------------------------------
462
+  (0.0ms) ROLLBACK
463
+  (0.0ms) BEGIN
464
+ ------------------------------------------------------------------------------
465
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
466
+ ------------------------------------------------------------------------------
467
+  (0.0ms) ROLLBACK
468
+  (0.0ms) BEGIN
469
+ -----------------------------------------------------------------------------------------------------
470
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
471
+ -----------------------------------------------------------------------------------------------------
472
+  (0.0ms) ROLLBACK
473
+  (0.0ms) BEGIN
474
+ -----------------------------------------------------------------------------------------
475
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
476
+ -----------------------------------------------------------------------------------------
477
+  (1.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
478
+ FROM pg_constraint c
479
+ JOIN pg_class t1 ON c.conrelid = t1.oid
480
+ JOIN pg_class t2 ON c.confrelid = t2.oid
481
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
482
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
483
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
484
+ WHERE c.contype = 'f'
485
+ AND t1.relname = 'comments'
486
+ AND t3.nspname = ANY (current_schemas(false))
487
+ ORDER BY c.conname
488
+ 
489
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
490
+ FROM pg_constraint c
491
+ JOIN pg_class t1 ON c.conrelid = t1.oid
492
+ JOIN pg_class t2 ON c.confrelid = t2.oid
493
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
494
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
495
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
496
+ WHERE c.contype = 'f'
497
+ AND t1.relname = 'users'
498
+ AND t3.nspname = ANY (current_schemas(false))
499
+ ORDER BY c.conname
500
+
501
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
502
+ FROM pg_constraint c
503
+ JOIN pg_class t1 ON c.conrelid = t1.oid
504
+ JOIN pg_class t2 ON c.confrelid = t2.oid
505
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
506
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
507
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
508
+ WHERE c.contype = 'f'
509
+ AND t1.relname = 'users'
510
+ AND t3.nspname = ANY (current_schemas(false))
511
+ ORDER BY c.conname
512
+ 
513
+  (0.1ms) ROLLBACK
514
+  (0.1ms) BEGIN
515
+ --------------------------------------------------------------------------------------
516
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
517
+ --------------------------------------------------------------------------------------
518
+  (0.0ms) ROLLBACK
519
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
520
+  (0.1ms) BEGIN
521
+ ---------------------------------------------------------------------------------------------
522
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
523
+ ---------------------------------------------------------------------------------------------
524
+  (0.0ms) ROLLBACK
525
+  (0.0ms) BEGIN
526
+ ------------------------------------------------------------------------------
527
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
528
+ ------------------------------------------------------------------------------
529
+  (0.0ms) ROLLBACK
530
+  (0.0ms) BEGIN
531
+ -----------------------------------------------------------------------------------------------------
532
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
533
+ -----------------------------------------------------------------------------------------------------
534
+  (0.0ms) ROLLBACK
535
+  (0.0ms) BEGIN
536
+ --------------------------------------------------------------------------------------
537
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
538
+ --------------------------------------------------------------------------------------
539
+  (0.0ms) ROLLBACK
540
+  (0.0ms) BEGIN
541
+ -----------------------------------------------------------------------------------------
542
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
543
+ -----------------------------------------------------------------------------------------
544
+  (1.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
545
+ FROM pg_constraint c
546
+ JOIN pg_class t1 ON c.conrelid = t1.oid
547
+ JOIN pg_class t2 ON c.confrelid = t2.oid
548
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
549
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
550
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
551
+ WHERE c.contype = 'f'
552
+ AND t1.relname = 'comments'
553
+ AND t3.nspname = ANY (current_schemas(false))
554
+ ORDER BY c.conname
555
+ 
556
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
557
+ FROM pg_constraint c
558
+ JOIN pg_class t1 ON c.conrelid = t1.oid
559
+ JOIN pg_class t2 ON c.confrelid = t2.oid
560
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
561
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
562
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
563
+ WHERE c.contype = 'f'
564
+ AND t1.relname = 'users'
565
+ AND t3.nspname = ANY (current_schemas(false))
566
+ ORDER BY c.conname
567
+
568
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
569
+ FROM pg_constraint c
570
+ JOIN pg_class t1 ON c.conrelid = t1.oid
571
+ JOIN pg_class t2 ON c.confrelid = t2.oid
572
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
573
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
574
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
575
+ WHERE c.contype = 'f'
576
+ AND t1.relname = 'users'
577
+ AND t3.nspname = ANY (current_schemas(false))
578
+ ORDER BY c.conname
579
+ 
580
+  (0.1ms) ROLLBACK
581
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
582
+  (0.1ms) BEGIN
583
+ ------------------------------------------------------------------------------
584
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
585
+ ------------------------------------------------------------------------------
586
+  (0.1ms) ROLLBACK
587
+  (0.1ms) BEGIN
588
+ --------------------------------------------------------------------------------------
589
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
590
+ --------------------------------------------------------------------------------------
591
+  (0.0ms) ROLLBACK
592
+  (0.0ms) BEGIN
593
+ ---------------------------------------------------------------------------------------------
594
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
595
+ ---------------------------------------------------------------------------------------------
596
+  (0.0ms) ROLLBACK
597
+  (0.0ms) BEGIN
598
+ -----------------------------------------------------------------------------------------------------
599
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
600
+ -----------------------------------------------------------------------------------------------------
601
+  (0.0ms) ROLLBACK
602
+  (0.0ms) BEGIN
603
+ -----------------------------------------------------------------------------------------
604
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
605
+ -----------------------------------------------------------------------------------------
606
+  (1.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
607
+ FROM pg_constraint c
608
+ JOIN pg_class t1 ON c.conrelid = t1.oid
609
+ JOIN pg_class t2 ON c.confrelid = t2.oid
610
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
611
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
612
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
613
+ WHERE c.contype = 'f'
614
+ AND t1.relname = 'comments'
615
+ AND t3.nspname = ANY (current_schemas(false))
616
+ ORDER BY c.conname
617
+ 
618
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
619
+ FROM pg_constraint c
620
+ JOIN pg_class t1 ON c.conrelid = t1.oid
621
+ JOIN pg_class t2 ON c.confrelid = t2.oid
622
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
623
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
624
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
625
+ WHERE c.contype = 'f'
626
+ AND t1.relname = 'users'
627
+ AND t3.nspname = ANY (current_schemas(false))
628
+ ORDER BY c.conname
629
+
630
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
631
+ FROM pg_constraint c
632
+ JOIN pg_class t1 ON c.conrelid = t1.oid
633
+ JOIN pg_class t2 ON c.confrelid = t2.oid
634
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
635
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
636
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
637
+ WHERE c.contype = 'f'
638
+ AND t1.relname = 'users'
639
+ AND t3.nspname = ANY (current_schemas(false))
640
+ ORDER BY c.conname
641
+ 
642
+  (0.1ms) ROLLBACK
643
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
644
+  (0.1ms) BEGIN
645
+ -----------------------------------------------------------------------------------------
646
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
647
+ -----------------------------------------------------------------------------------------
648
+  (1.5ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
649
+ FROM pg_constraint c
650
+ JOIN pg_class t1 ON c.conrelid = t1.oid
651
+ JOIN pg_class t2 ON c.confrelid = t2.oid
652
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
653
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
654
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
655
+ WHERE c.contype = 'f'
656
+ AND t1.relname = 'comments'
657
+ AND t3.nspname = ANY (current_schemas(false))
658
+ ORDER BY c.conname
659
+ 
660
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
661
+ FROM pg_constraint c
662
+ JOIN pg_class t1 ON c.conrelid = t1.oid
663
+ JOIN pg_class t2 ON c.confrelid = t2.oid
664
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
665
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
666
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
667
+ WHERE c.contype = 'f'
668
+ AND t1.relname = 'users'
669
+ AND t3.nspname = ANY (current_schemas(false))
670
+ ORDER BY c.conname
671
+
672
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
673
+ FROM pg_constraint c
674
+ JOIN pg_class t1 ON c.conrelid = t1.oid
675
+ JOIN pg_class t2 ON c.confrelid = t2.oid
676
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
677
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
678
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
679
+ WHERE c.contype = 'f'
680
+ AND t1.relname = 'users'
681
+ AND t3.nspname = ANY (current_schemas(false))
682
+ ORDER BY c.conname
683
+ 
684
+  (0.1ms) ROLLBACK
685
+  (0.1ms) BEGIN
686
+ ------------------------------------------------------------------------------
687
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
688
+ ------------------------------------------------------------------------------
689
+  (0.1ms) ROLLBACK
690
+  (0.1ms) BEGIN
691
+ --------------------------------------------------------------------------------------
692
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
693
+ --------------------------------------------------------------------------------------
694
+  (0.0ms) ROLLBACK
695
+  (0.0ms) BEGIN
696
+ -----------------------------------------------------------------------------------------------------
697
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
698
+ -----------------------------------------------------------------------------------------------------
699
+  (0.0ms) ROLLBACK
700
+  (0.0ms) BEGIN
701
+ ---------------------------------------------------------------------------------------------
702
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
703
+ ---------------------------------------------------------------------------------------------
704
+  (0.0ms) ROLLBACK
705
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
706
+  (0.2ms) BEGIN
707
+ -----------------------------------------------------------------------------------------
708
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
709
+ -----------------------------------------------------------------------------------------
710
+  (1.5ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
711
+ FROM pg_constraint c
712
+ JOIN pg_class t1 ON c.conrelid = t1.oid
713
+ JOIN pg_class t2 ON c.confrelid = t2.oid
714
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
715
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
716
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
717
+ WHERE c.contype = 'f'
718
+ AND t1.relname = 'comments'
719
+ AND t3.nspname = ANY (current_schemas(false))
720
+ ORDER BY c.conname
721
+ 
722
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
723
+ FROM pg_constraint c
724
+ JOIN pg_class t1 ON c.conrelid = t1.oid
725
+ JOIN pg_class t2 ON c.confrelid = t2.oid
726
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
727
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
728
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
729
+ WHERE c.contype = 'f'
730
+ AND t1.relname = 'users'
731
+ AND t3.nspname = ANY (current_schemas(false))
732
+ ORDER BY c.conname
733
+
734
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
735
+ FROM pg_constraint c
736
+ JOIN pg_class t1 ON c.conrelid = t1.oid
737
+ JOIN pg_class t2 ON c.confrelid = t2.oid
738
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
739
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
740
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
741
+ WHERE c.contype = 'f'
742
+ AND t1.relname = 'users'
743
+ AND t3.nspname = ANY (current_schemas(false))
744
+ ORDER BY c.conname
745
+ 
746
+  (0.2ms) ROLLBACK
747
+  (0.1ms) BEGIN
748
+ -----------------------------------------------------------------------------------------------------
749
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
750
+ -----------------------------------------------------------------------------------------------------
751
+  (0.1ms) ROLLBACK
752
+  (0.1ms) BEGIN
753
+ --------------------------------------------------------------------------------------
754
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
755
+ --------------------------------------------------------------------------------------
756
+  (0.0ms) ROLLBACK
757
+  (0.0ms) BEGIN
758
+ ---------------------------------------------------------------------------------------------
759
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
760
+ ---------------------------------------------------------------------------------------------
761
+  (0.0ms) ROLLBACK
762
+  (0.0ms) BEGIN
763
+ ------------------------------------------------------------------------------
764
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
765
+ ------------------------------------------------------------------------------
766
+  (0.0ms) ROLLBACK
767
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
768
+  (0.1ms) BEGIN
769
+ ---------------------------------------------------------------------------------------------
770
+ ActiveRecordDoctor::Tasks::UnindexedForeignKeysTest: test_unindexed_foreign_keys_are_reported
771
+ ---------------------------------------------------------------------------------------------
772
+  (0.0ms) ROLLBACK
773
+  (0.0ms) BEGIN
774
+ -----------------------------------------------------------------------------------------------------
775
+ ActiveRecordDoctor::Tasks::UndefinedTableReferencesTest: test_undefined_table_references_are_reported
776
+ -----------------------------------------------------------------------------------------------------
777
+  (0.1ms) ROLLBACK
778
+  (0.1ms) BEGIN
779
+ -----------------------------------------------------------------------------------------
780
+ ActiveRecordDoctor::Tasks::MissingForeignKeysTest: test_missing_foreign_keys_are_reported
781
+ -----------------------------------------------------------------------------------------
782
+  (1.3ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
783
+ FROM pg_constraint c
784
+ JOIN pg_class t1 ON c.conrelid = t1.oid
785
+ JOIN pg_class t2 ON c.confrelid = t2.oid
786
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
787
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
788
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
789
+ WHERE c.contype = 'f'
790
+ AND t1.relname = 'comments'
791
+ AND t3.nspname = ANY (current_schemas(false))
792
+ ORDER BY c.conname
793
+ 
794
+  (1.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
795
+ FROM pg_constraint c
796
+ JOIN pg_class t1 ON c.conrelid = t1.oid
797
+ JOIN pg_class t2 ON c.confrelid = t2.oid
798
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
799
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
800
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
801
+ WHERE c.contype = 'f'
802
+ AND t1.relname = 'users'
803
+ AND t3.nspname = ANY (current_schemas(false))
804
+ ORDER BY c.conname
805
+
806
+  (1.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
807
+ FROM pg_constraint c
808
+ JOIN pg_class t1 ON c.conrelid = t1.oid
809
+ JOIN pg_class t2 ON c.confrelid = t2.oid
810
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
811
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
812
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
813
+ WHERE c.contype = 'f'
814
+ AND t1.relname = 'users'
815
+ AND t3.nspname = ANY (current_schemas(false))
816
+ ORDER BY c.conname
817
+ 
818
+  (0.1ms) ROLLBACK
819
+  (0.0ms) BEGIN
820
+ ------------------------------------------------------------------------------
821
+ ActiveRecordDoctor::Printers::IOPrinterTest: test_print_unindexed_foreign_keys
822
+ ------------------------------------------------------------------------------
823
+  (0.1ms) ROLLBACK
824
+  (0.1ms) BEGIN
825
+ --------------------------------------------------------------------------------------
826
+ ActiveRecordDoctor::Tasks::ExtraneousIndexesTest: test_extraneous_indexes_are_reported
827
+ --------------------------------------------------------------------------------------
828
+  (0.0ms) ROLLBACK
@@ -1,11 +1,12 @@
1
1
  class SpyPrinter
2
2
  attr_reader :unindexed_foreign_keys, :extraneous_indexes,
3
- :missing_foreign_keys
3
+ :missing_foreign_keys, :undefined_table_references
4
4
 
5
5
  def initialize
6
6
  @unindexed_foreign_keys = nil
7
7
  @extraneous_indexes = nil
8
8
  @missing_foreign_keys = nil
9
+ @undefined_table_references = nil
9
10
  end
10
11
 
11
12
  def print_unindexed_foreign_keys(argument)
@@ -31,4 +32,12 @@ class SpyPrinter
31
32
  @missing_foreign_keys = argument
32
33
  end
33
34
  end
35
+
36
+ def print_undefined_table_references(argument)
37
+ if @undefined_table_references
38
+ fail("print_undefined_table_references cannot be called twice")
39
+ else
40
+ @undefined_table_references = argument
41
+ end
42
+ end
34
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_doctor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Navis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-18 00:00:00.000000000 Z
11
+ date: 2017-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -84,6 +84,7 @@ files:
84
84
  - lib/active_record_doctor/tasks.rb
85
85
  - lib/active_record_doctor/tasks/extraneous_indexes.rb
86
86
  - lib/active_record_doctor/tasks/missing_foreign_keys.rb
87
+ - lib/active_record_doctor/tasks/undefined_table_references.rb
87
88
  - lib/active_record_doctor/tasks/unindexed_foreign_keys.rb
88
89
  - lib/active_record_doctor/version.rb
89
90
  - lib/generators/active_record_doctor/add_indexes/USAGE
@@ -92,6 +93,7 @@ files:
92
93
  - test/active_record_doctor/printers/io_printer_test.rb
93
94
  - test/active_record_doctor/tasks/extraneous_indexes_test.rb
94
95
  - test/active_record_doctor/tasks/missing_foreign_keys_test.rb
96
+ - test/active_record_doctor/tasks/undefined_table_references_test.rb
95
97
  - test/active_record_doctor/tasks/unindexed_foreign_keys_test.rb
96
98
  - test/dummy/README.rdoc
97
99
  - test/dummy/Rakefile
@@ -100,6 +102,7 @@ files:
100
102
  - test/dummy/app/controllers/application_controller.rb
101
103
  - test/dummy/app/helpers/application_helper.rb
102
104
  - test/dummy/app/models/comment.rb
105
+ - test/dummy/app/models/contract.rb
103
106
  - test/dummy/app/models/employer.rb
104
107
  - test/dummy/app/models/profile.rb
105
108
  - test/dummy/app/models/user.rb
@@ -171,6 +174,7 @@ test_files:
171
174
  - test/active_record_doctor/printers/io_printer_test.rb
172
175
  - test/active_record_doctor/tasks/missing_foreign_keys_test.rb
173
176
  - test/active_record_doctor/tasks/extraneous_indexes_test.rb
177
+ - test/active_record_doctor/tasks/undefined_table_references_test.rb
174
178
  - test/active_record_doctor/tasks/unindexed_foreign_keys_test.rb
175
179
  - test/dummy/README.rdoc
176
180
  - test/dummy/log/development.log
@@ -186,6 +190,7 @@ test_files:
186
190
  - test/dummy/app/views/layouts/application.html.erb
187
191
  - test/dummy/app/models/profile.rb
188
192
  - test/dummy/app/models/comment.rb
193
+ - test/dummy/app/models/contract.rb
189
194
  - test/dummy/app/models/employer.rb
190
195
  - test/dummy/app/models/user.rb
191
196
  - test/dummy/db/schema.rb