rails3_pg_deferred_constraints 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -14,3 +14,8 @@ Add to your Gemfile:
14
14
  group :test do
15
15
  gem 'rails3_pg_deferred_constraints'
16
16
  end
17
+
18
+ # Testing
19
+
20
+ * Open ./test/dummy/config/database.yml and modified db connections
21
+ * Run `rake test` from the root directory of gem(not dummy application)
data/Rakefile CHANGED
@@ -27,9 +27,8 @@ Bundler::GemHelper.install_tasks
27
27
  require 'rake/testtask'
28
28
 
29
29
  Rake::TestTask.new(:test) do |t|
30
- t.libs << 'lib'
31
30
  t.libs << 'test'
32
- t.pattern = 'test/**/*_test.rb'
31
+ t.pattern = 'test/rails3_pg_deferred_constraints_test.rb'
33
32
  t.verbose = false
34
33
  end
35
34
 
@@ -5,6 +5,9 @@
5
5
  #
6
6
  # source: http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error
7
7
  # ref: https://github.com/matthuhiggins/foreigner/issues/61
8
+
9
+ ActiveRecord::Base
10
+
8
11
  class ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter < ::ActiveRecord::ConnectionAdapters::AbstractAdapter
9
12
 
10
13
  alias_method :supports_deferring_all_constraints?, :supports_disable_referential_integrity?
@@ -1,3 +1,3 @@
1
1
  module Rails3PgDeferredConstraints
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'foreigner'
4
+ gem 'rails'
5
+ gem 'pg'
@@ -0,0 +1,92 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.0)
5
+ actionpack (= 3.1.0)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.0)
8
+ activemodel (= 3.1.0)
9
+ activesupport (= 3.1.0)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.2)
14
+ rack-cache (~> 1.0.3)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.0)
18
+ activemodel (3.1.0)
19
+ activesupport (= 3.1.0)
20
+ bcrypt-ruby (~> 3.0.0)
21
+ builder (~> 3.0.0)
22
+ i18n (~> 0.6)
23
+ activerecord (3.1.0)
24
+ activemodel (= 3.1.0)
25
+ activesupport (= 3.1.0)
26
+ arel (~> 2.2.1)
27
+ tzinfo (~> 0.3.29)
28
+ activeresource (3.1.0)
29
+ activemodel (= 3.1.0)
30
+ activesupport (= 3.1.0)
31
+ activesupport (3.1.0)
32
+ multi_json (~> 1.0)
33
+ arel (2.2.1)
34
+ bcrypt-ruby (3.0.0)
35
+ builder (3.0.0)
36
+ erubis (2.7.0)
37
+ foreigner (1.1.1)
38
+ activerecord (>= 3.0.0)
39
+ hike (1.2.1)
40
+ i18n (0.6.0)
41
+ mail (2.3.0)
42
+ i18n (>= 0.4.0)
43
+ mime-types (~> 1.16)
44
+ treetop (~> 1.4.8)
45
+ mime-types (1.16)
46
+ multi_json (1.0.3)
47
+ pg (0.11.0)
48
+ polyglot (0.3.2)
49
+ rack (1.3.2)
50
+ rack-cache (1.0.3)
51
+ rack (>= 0.4)
52
+ rack-mount (0.8.3)
53
+ rack (>= 1.0.0)
54
+ rack-ssl (1.3.2)
55
+ rack
56
+ rack-test (0.6.1)
57
+ rack (>= 1.0)
58
+ rails (3.1.0)
59
+ actionmailer (= 3.1.0)
60
+ actionpack (= 3.1.0)
61
+ activerecord (= 3.1.0)
62
+ activeresource (= 3.1.0)
63
+ activesupport (= 3.1.0)
64
+ bundler (~> 1.0)
65
+ railties (= 3.1.0)
66
+ railties (3.1.0)
67
+ actionpack (= 3.1.0)
68
+ activesupport (= 3.1.0)
69
+ rack-ssl (~> 1.3.2)
70
+ rake (>= 0.8.7)
71
+ rdoc (~> 3.4)
72
+ thor (~> 0.14.6)
73
+ rake (0.9.2)
74
+ rdoc (3.9.4)
75
+ sprockets (2.0.0)
76
+ hike (~> 1.2)
77
+ rack (~> 1.0)
78
+ tilt (!= 1.3.0, ~> 1.1)
79
+ thor (0.14.6)
80
+ tilt (1.3.3)
81
+ treetop (1.4.10)
82
+ polyglot
83
+ polyglot (>= 0.3.1)
84
+ tzinfo (0.3.29)
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ foreigner
91
+ pg
92
+ rails
@@ -0,0 +1,2 @@
1
+ class Book < ActiveRecord::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class User < ActiveRecord::Base
2
+ end
@@ -3,7 +3,8 @@ require File.expand_path('../boot', __FILE__)
3
3
  require 'rails/all'
4
4
 
5
5
  Bundler.require
6
- require "rails3_pg_deferred_constraints"
6
+
7
+ require "rails3_pg_deferred_constraints" if ENV['PG_DEFERRED_CONSTRAINTS'] == 'true'
7
8
 
8
9
  module Dummy
9
10
  class Application < Rails::Application
@@ -1,10 +1,8 @@
1
1
  require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
2
 
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
5
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
6
+
9
7
 
10
8
  $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -4,22 +4,25 @@
4
4
  # Ensure the SQLite 3 gem is defined in your Gemfile
5
5
  # gem 'sqlite3'
6
6
  development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
7
+ adapter: postgresql
8
+ encoding: unicode
9
+ database: tmp_fix_development
9
10
  pool: 5
10
- timeout: 5000
11
+ host: localhost
12
+ port: 5432
13
+ username: rails_bug
14
+ password: secret
15
+
11
16
 
12
17
  # Warning: The database defined as "test" will be erased and
13
18
  # re-generated from your development database when you run "rake".
14
19
  # Do not set this db to the same as development or production.
15
20
  test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
20
-
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
21
+ adapter: postgresql
22
+ encoding: unicode
23
+ database: tmp_fix_test
24
24
  pool: 5
25
- timeout: 5000
25
+ host: localhost
26
+ port: 5432
27
+ username: rails_bug
28
+ password: secret
@@ -0,0 +1,9 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class CreateBooks < ActiveRecord::Migration
2
+ def change
3
+ create_table :books do |t|
4
+ t.string :name
5
+ t.integer :user_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ class AddReferences < ActiveRecord::Migration
2
+ def up
3
+ add_foreign_key(:books, :users, :column => 'user_id')
4
+ end
5
+
6
+ def down
7
+ change_table :books do |t|
8
+ t.remove_foreign_key :users
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20110909072642) do
15
+
16
+ create_table "books", :force => true do |t|
17
+ t.string "name"
18
+ t.integer "user_id"
19
+ t.datetime "created_at"
20
+ t.datetime "updated_at"
21
+ end
22
+
23
+ create_table "users", :force => true do |t|
24
+ t.string "name"
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ end
28
+
29
+ add_foreign_key "books", "users", :name => "books_user_id_fk"
30
+
31
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
@@ -0,0 +1,234 @@
1
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
2
+  (0.1ms) SET search_path TO public
3
+  (0.1ms) DROP DATABASE IF EXISTS "tmp_fix_test"
4
+  (0.1ms) SET search_path TO public
5
+  (0.2ms) CREATE DATABASE "tmp_fix_test" ENCODING = 'unicode'
6
+ PGError: ERROR: permission denied to create database
7
+ : CREATE DATABASE "tmp_fix_test" ENCODING = 'unicode'
8
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
9
+  (0.1ms) SET search_path TO public
10
+  (245.4ms) DROP DATABASE IF EXISTS "tmp_fix_test"
11
+  (0.1ms) SET search_path TO public
12
+  (0.2ms) CREATE DATABASE "tmp_fix_test" ENCODING = 'unicode'
13
+ PGError: ERROR: permission denied to create database
14
+ : CREATE DATABASE "tmp_fix_test" ENCODING = 'unicode'
15
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
16
+ Migrating to CreateUsers (20110908165659)
17
+ Migrating to CreateBooks (20110908165716)
18
+ Migrating to AddReferences (20110909072642)
19
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
20
+  (0.1ms) SHOW search_path
21
+  (1.5ms) SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
22
+ FROM pg_class t
23
+ INNER JOIN pg_index d ON t.oid = d.indrelid
24
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
25
+ WHERE i.relkind = 'i'
26
+ AND d.indisprimary = 'f'
27
+ AND t.relname = 'books'
28
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
29
+ ORDER BY i.relname
30
+  (0.8ms)  SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
31
+ FROM pg_class t
32
+ INNER JOIN pg_index d ON t.oid = d.indrelid
33
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
34
+ WHERE i.relkind = 'i'
35
+ AND d.indisprimary = 'f'
36
+ AND t.relname = 'users'
37
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
38
+ ORDER BY i.relname
39
+ 
40
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
41
+ Migrating to CreateUsers (20110908165659)
42
+ Migrating to CreateBooks (20110908165716)
43
+ Migrating to AddReferences (20110909072642)
44
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
45
+  (0.1ms) SHOW search_path
46
+  (2.3ms) SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
47
+ FROM pg_class t
48
+ INNER JOIN pg_index d ON t.oid = d.indrelid
49
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
50
+ WHERE i.relkind = 'i'
51
+ AND d.indisprimary = 'f'
52
+ AND t.relname = 'books'
53
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
54
+ ORDER BY i.relname
55
+  (0.8ms)  SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
56
+ FROM pg_class t
57
+ INNER JOIN pg_index d ON t.oid = d.indrelid
58
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
59
+ WHERE i.relkind = 'i'
60
+ AND d.indisprimary = 'f'
61
+ AND t.relname = 'users'
62
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
63
+ ORDER BY i.relname
64
+ 
65
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
66
+ Migrating to CreateUsers (20110908165659)
67
+ Migrating to CreateBooks (20110908165716)
68
+ Migrating to AddReferences (20110909072642)
69
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
70
+  (0.2ms) SHOW search_path
71
+  (1.6ms) SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
72
+ FROM pg_class t
73
+ INNER JOIN pg_index d ON t.oid = d.indrelid
74
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
75
+ WHERE i.relkind = 'i'
76
+ AND d.indisprimary = 'f'
77
+ AND t.relname = 'books'
78
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
79
+ ORDER BY i.relname
80
+  (1.0ms)  SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
81
+ FROM pg_class t
82
+ INNER JOIN pg_index d ON t.oid = d.indrelid
83
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
84
+ WHERE i.relkind = 'i'
85
+ AND d.indisprimary = 'f'
86
+ AND t.relname = 'users'
87
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
88
+ ORDER BY i.relname
89
+ 
90
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
91
+  (0.1ms) SET search_path TO public
92
+  (213.5ms) DROP DATABASE IF EXISTS "tmp_fix_test"
93
+  (0.1ms) SET search_path TO public
94
+  (0.2ms) CREATE DATABASE "tmp_fix_test" ENCODING = 'unicode'
95
+ PGError: ERROR: permission denied to create database
96
+ : CREATE DATABASE "tmp_fix_test" ENCODING = 'unicode'
97
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
98
+  (0.1ms) SET search_path TO public
99
+  (0.1ms) DROP DATABASE IF EXISTS "tmp_fix_test"
100
+  (0.1ms) SET search_path TO public
101
+  (0.3ms) CREATE DATABASE "tmp_fix_test" ENCODING = 'unicode'
102
+ PGError: ERROR: permission denied to create database
103
+ : CREATE DATABASE "tmp_fix_test" ENCODING = 'unicode'
104
+  (50.6ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
105
+  (0.1ms) SHOW search_path
106
+  (2.1ms)  SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
107
+ FROM pg_class t
108
+ INNER JOIN pg_index d ON t.oid = d.indrelid
109
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
110
+ WHERE i.relkind = 'i'
111
+ AND d.indisprimary = 'f'
112
+ AND t.relname = 'schema_migrations'
113
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
114
+ ORDER BY i.relname
115
+ 
116
+  (39.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
117
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
118
+ Migrating to CreateUsers (20110908165659)
119
+  (0.1ms) BEGIN
120
+  (37.5ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
121
+  (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110908165659')
122
+  (63.1ms) COMMIT
123
+ Migrating to CreateBooks (20110908165716)
124
+  (0.1ms) BEGIN
125
+  (33.0ms) CREATE TABLE "books" ("id" serial primary key, "name" character varying(255), "user_id" integer, "created_at" timestamp, "updated_at" timestamp) 
126
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110908165716')
127
+  (5.1ms) COMMIT
128
+ Migrating to AddReferences (20110909072642)
129
+  (0.1ms) BEGIN
130
+  (0.1ms) ROLLBACK
131
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
132
+ Migrating to CreateUsers (20110908165659)
133
+ Migrating to CreateBooks (20110908165716)
134
+ Migrating to AddReferences (20110909072642)
135
+  (0.1ms) BEGIN
136
+  (0.1ms) ROLLBACK
137
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
138
+ Migrating to CreateUsers (20110908165659)
139
+ Migrating to CreateBooks (20110908165716)
140
+ Migrating to AddReferences (20110909072642)
141
+  (0.1ms) BEGIN
142
+  (0.1ms) ROLLBACK
143
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
144
+ Migrating to CreateUsers (20110908165659)
145
+ Migrating to CreateBooks (20110908165716)
146
+ Migrating to AddReferences (20110909072642)
147
+  (0.1ms) BEGIN
148
+  (0.5ms) ROLLBACK
149
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
150
+ Migrating to CreateUsers (20110908165659)
151
+ Migrating to CreateBooks (20110908165716)
152
+ Migrating to AddReferences (20110909072642)
153
+  (0.1ms) BEGIN
154
+  (0.1ms) ROLLBACK
155
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
156
+ Migrating to CreateUsers (20110908165659)
157
+ Migrating to CreateBooks (20110908165716)
158
+ Migrating to AddReferences (20110909072642)
159
+  (0.1ms) BEGIN
160
+  (0.1ms) ROLLBACK
161
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
162
+ Migrating to CreateUsers (20110908165659)
163
+ Migrating to CreateBooks (20110908165716)
164
+ Migrating to AddReferences (20110909072642)
165
+  (0.1ms) BEGIN
166
+  (0.1ms) ROLLBACK
167
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
168
+ Migrating to CreateUsers (20110908165659)
169
+ Migrating to CreateBooks (20110908165716)
170
+ Migrating to AddReferences (20110909072642)
171
+  (0.1ms) BEGIN
172
+  (2.0ms) ALTER TABLE "books" ADD CONSTRAINT "books_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"(id)
173
+  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110909072642')
174
+  (17.0ms) COMMIT
175
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
176
+  (0.1ms) SHOW search_path
177
+  (1.3ms) SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
178
+ FROM pg_class t
179
+ INNER JOIN pg_index d ON t.oid = d.indrelid
180
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
181
+ WHERE i.relkind = 'i'
182
+ AND d.indisprimary = 'f'
183
+ AND t.relname = 'books'
184
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
185
+ ORDER BY i.relname
186
+  (0.8ms)  SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
187
+ FROM pg_class t
188
+ INNER JOIN pg_index d ON t.oid = d.indrelid
189
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
190
+ WHERE i.relkind = 'i'
191
+ AND d.indisprimary = 'f'
192
+ AND t.relname = 'users'
193
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
194
+ ORDER BY i.relname
195
+ 
196
+  (2.9ms)
197
+ SELECT t2.relname AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confdeltype AS dependency
198
+ FROM pg_constraint c
199
+ JOIN pg_class t1 ON c.conrelid = t1.oid
200
+ JOIN pg_class t2 ON c.confrelid = t2.oid
201
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
202
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
203
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
204
+ WHERE c.contype = 'f'
205
+ AND t1.relname = 'books'
206
+ AND t3.nspname = ANY (current_schemas(false))
207
+ ORDER BY c.conname
208
+
209
+  (3.0ms) 
210
+ SELECT t2.relname AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confdeltype AS dependency
211
+ FROM pg_constraint c
212
+ JOIN pg_class t1 ON c.conrelid = t1.oid
213
+ JOIN pg_class t2 ON c.confrelid = t2.oid
214
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
215
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
216
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
217
+ WHERE c.contype = 'f'
218
+ AND t1.relname = 'schema_migrations'
219
+ AND t3.nspname = ANY (current_schemas(false))
220
+ ORDER BY c.conname
221
+ 
222
+  (2.7ms)
223
+ SELECT t2.relname AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confdeltype AS dependency
224
+ FROM pg_constraint c
225
+ JOIN pg_class t1 ON c.conrelid = t1.oid
226
+ JOIN pg_class t2 ON c.confrelid = t2.oid
227
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
228
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
229
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
230
+ WHERE c.contype = 'f'
231
+ AND t1.relname = 'users'
232
+ AND t3.nspname = ANY (current_schemas(false))
233
+ ORDER BY c.conname
234
+