rails_db_views 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,22 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_db_views
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yacine Petitprez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-08 00:00:00.000000000 Z
11
+ date: 2016-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '4'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: '4.0'
@@ -24,9 +21,6 @@ dependencies:
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '4'
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
26
  version: '4.0'
@@ -78,6 +72,7 @@ files:
78
72
  - lib/rails_db_views.rb
79
73
  - lib/rails_db_views/configuration.rb
80
74
  - lib/rails_db_views/database_symbol.rb
75
+ - lib/rails_db_views/exceptions.rb
81
76
  - lib/rails_db_views/factory.rb
82
77
  - lib/rails_db_views/function.rb
83
78
  - lib/rails_db_views/railtie.rb
@@ -124,7 +119,6 @@ files:
124
119
  - test/dummy/db/views/messages.sql
125
120
  - test/dummy/lib/tasks/test.rake
126
121
  - test/dummy/log/development.log
127
- - test/dummy/log/test.log
128
122
  - test/dummy/public/404.html
129
123
  - test/dummy/public/422.html
130
124
  - test/dummy/public/500.html
@@ -194,7 +188,6 @@ test_files:
194
188
  - test/dummy/db/views/messages.sql
195
189
  - test/dummy/lib/tasks/test.rake
196
190
  - test/dummy/log/development.log
197
- - test/dummy/log/test.log
198
191
  - test/dummy/public/404.html
199
192
  - test/dummy/public/422.html
200
193
  - test/dummy/public/500.html
@@ -1,2635 +0,0 @@
1
-  (0.3ms) DROP VIEW messages
2
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
3
-  (0.3ms) DROP VIEW messages
4
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
5
-  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
6
-  (0.3ms) select sqlite_version(*)
7
-  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
8
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
9
- Migrating to CreateTestTables (20160208084226)
10
-  (0.1ms) begin transaction
11
-  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime) 
12
-  (0.2ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
13
-  (0.4ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime, "updated_at" datetime) 
14
-  (0.5ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
15
-  (0.1ms)  SELECT sql
16
- FROM sqlite_master
17
- WHERE name='index_user_messages_on_from_id' AND type='index'
18
- UNION ALL
19
- SELECT sql
20
- FROM sqlite_temp_master
21
- WHERE name='index_user_messages_on_from_id' AND type='index'
22
- 
23
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
24
- SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
25
-  (0.6ms) commit transaction
26
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
27
-  (0.1ms) SELECT sql
28
- FROM sqlite_master
29
- WHERE name='index_user_messages_on_to_id' AND type='index'
30
- UNION ALL
31
- SELECT sql
32
- FROM sqlite_temp_master
33
- WHERE name='index_user_messages_on_to_id' AND type='index'
34
-
35
-  (0.1ms)  SELECT sql
36
- FROM sqlite_master
37
- WHERE name='index_user_messages_on_from_id' AND type='index'
38
- UNION ALL
39
- SELECT sql
40
- FROM sqlite_temp_master
41
- WHERE name='index_user_messages_on_from_id' AND type='index'
42
- 
43
-  (0.1ms) SELECT sql
44
- FROM sqlite_master
45
- WHERE name='index_users_on_name' AND type='index'
46
- UNION ALL
47
- SELECT sql
48
- FROM sqlite_temp_master
49
- WHERE name='index_users_on_name' AND type='index'
50
-
51
-  (0.1ms) CREATE VIEW messages AS -- Sample virtual model to test the gem.
52
- (
53
- SELECT u2.name as receiver_name, u2.id as receiver_id,
54
- u1.name as sender_name, u1.id as sender_id,
55
- um.content, um.updated_at, um.created_at
56
- FROM users u
57
- INNER JOIN users_messages um ON ( u.id = users_messages.from_id )
58
- INNER JOIN users u2 ON (u2.id = users_messages.to_id)
59
- )
60
- UNION
61
- (
62
- SELECT u.name as receiver_name, u.id as receiver_id,
63
- u2.name as sender_name, u2.id as sender_id,
64
- um.content, um.updated_at, um.created_at
65
- FROM users u
66
- INNER JOIN users_messages um ON ( u.id = users_messages.to_id )
67
- INNER JOIN users u2 ON ( u2.id = users_messages.from_id )
68
- )
69
- ORDER BY created_at ASC
70
- SQLite3::SQLException: near "(": syntax error: CREATE VIEW messages AS -- Sample virtual model to test the gem.
71
- (
72
- SELECT u2.name as receiver_name, u2.id as receiver_id,
73
- u1.name as sender_name, u1.id as sender_id,
74
- um.content, um.updated_at, um.created_at
75
- FROM users u
76
- INNER JOIN users_messages um ON ( u.id = users_messages.from_id )
77
- INNER JOIN users u2 ON (u2.id = users_messages.to_id)
78
- )
79
- UNION
80
- (
81
- SELECT u.name as receiver_name, u.id as receiver_id,
82
- u2.name as sender_name, u2.id as sender_id,
83
- um.content, um.updated_at, um.created_at
84
- FROM users u
85
- INNER JOIN users_messages um ON ( u.id = users_messages.to_id )
86
- INNER JOIN users u2 ON ( u2.id = users_messages.from_id )
87
- )
88
- ORDER BY created_at ASC
89
-  (0.3ms) DROP VIEW messages
90
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
91
-  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
92
-  (0.1ms) select sqlite_version(*)
93
-  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
94
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
95
- Migrating to CreateTestTables (20160208084226)
96
-  (0.1ms) begin transaction
97
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime) 
98
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
99
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime, "updated_at" datetime) 
100
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
101
-  (0.1ms)  SELECT sql
102
- FROM sqlite_master
103
- WHERE name='index_user_messages_on_from_id' AND type='index'
104
- UNION ALL
105
- SELECT sql
106
- FROM sqlite_temp_master
107
- WHERE name='index_user_messages_on_from_id' AND type='index'
108
- 
109
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
110
- SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
111
-  (2.1ms) commit transaction
112
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
113
-  (0.1ms) SELECT sql
114
- FROM sqlite_master
115
- WHERE name='index_user_messages_on_to_id' AND type='index'
116
- UNION ALL
117
- SELECT sql
118
- FROM sqlite_temp_master
119
- WHERE name='index_user_messages_on_to_id' AND type='index'
120
-
121
-  (0.1ms)  SELECT sql
122
- FROM sqlite_master
123
- WHERE name='index_user_messages_on_from_id' AND type='index'
124
- UNION ALL
125
- SELECT sql
126
- FROM sqlite_temp_master
127
- WHERE name='index_user_messages_on_from_id' AND type='index'
128
- 
129
-  (0.1ms) SELECT sql
130
- FROM sqlite_master
131
- WHERE name='index_users_on_name' AND type='index'
132
- UNION ALL
133
- SELECT sql
134
- FROM sqlite_temp_master
135
- WHERE name='index_users_on_name' AND type='index'
136
-
137
-  (0.1ms) CREATE VIEW messages AS (
138
- SELECT u2.name as receiver_name, u2.id as receiver_id,
139
- u1.name as sender_name, u1.id as sender_id,
140
- um.content, um.updated_at, um.created_at
141
- FROM users u
142
- INNER JOIN users_messages um ON ( u.id = users_messages.from_id )
143
- INNER JOIN users u2 ON (u2.id = users_messages.to_id)
144
- )
145
- UNION
146
- (
147
- SELECT u.name as receiver_name, u.id as receiver_id,
148
- u2.name as sender_name, u2.id as sender_id,
149
- um.content, um.updated_at, um.created_at
150
- FROM users u
151
- INNER JOIN users_messages um ON ( u.id = users_messages.to_id )
152
- INNER JOIN users u2 ON ( u2.id = users_messages.from_id )
153
- )
154
- ORDER BY created_at ASC
155
- SQLite3::SQLException: near "(": syntax error: CREATE VIEW messages AS (
156
- SELECT u2.name as receiver_name, u2.id as receiver_id,
157
- u1.name as sender_name, u1.id as sender_id,
158
- um.content, um.updated_at, um.created_at
159
- FROM users u
160
- INNER JOIN users_messages um ON ( u.id = users_messages.from_id )
161
- INNER JOIN users u2 ON (u2.id = users_messages.to_id)
162
- )
163
- UNION
164
- (
165
- SELECT u.name as receiver_name, u.id as receiver_id,
166
- u2.name as sender_name, u2.id as sender_id,
167
- um.content, um.updated_at, um.created_at
168
- FROM users u
169
- INNER JOIN users_messages um ON ( u.id = users_messages.to_id )
170
- INNER JOIN users u2 ON ( u2.id = users_messages.from_id )
171
- )
172
- ORDER BY created_at ASC
173
-  (0.3ms) DROP VIEW messages
174
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
175
-  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
176
-  (0.1ms) select sqlite_version(*)
177
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
178
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
179
- Migrating to CreateTestTables (20160208084226)
180
-  (0.1ms) begin transaction
181
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime) 
182
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
183
-  (0.2ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime, "updated_at" datetime) 
184
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
185
-  (0.1ms)  SELECT sql
186
- FROM sqlite_master
187
- WHERE name='index_user_messages_on_from_id' AND type='index'
188
- UNION ALL
189
- SELECT sql
190
- FROM sqlite_temp_master
191
- WHERE name='index_user_messages_on_from_id' AND type='index'
192
- 
193
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
194
- SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
195
-  (2.1ms) commit transaction
196
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
197
-  (0.1ms) SELECT sql
198
- FROM sqlite_master
199
- WHERE name='index_user_messages_on_to_id' AND type='index'
200
- UNION ALL
201
- SELECT sql
202
- FROM sqlite_temp_master
203
- WHERE name='index_user_messages_on_to_id' AND type='index'
204
-
205
-  (0.1ms)  SELECT sql
206
- FROM sqlite_master
207
- WHERE name='index_user_messages_on_from_id' AND type='index'
208
- UNION ALL
209
- SELECT sql
210
- FROM sqlite_temp_master
211
- WHERE name='index_user_messages_on_from_id' AND type='index'
212
- 
213
-  (0.1ms) SELECT sql
214
- FROM sqlite_master
215
- WHERE name='index_users_on_name' AND type='index'
216
- UNION ALL
217
- SELECT sql
218
- FROM sqlite_temp_master
219
- WHERE name='index_users_on_name' AND type='index'
220
-
221
-  (0.2ms) CREATE VIEW messages AS
222
- SELECT u2.name as receiver_name, u2.id as receiver_id,
223
- u1.name as sender_name, u1.id as sender_id,
224
- um.content, um.updated_at, um.created_at
225
- FROM users u
226
- INNER JOIN users_messages um ON ( u.id = users_messages.from_id )
227
- INNER JOIN users u2 ON (u2.id = users_messages.to_id)
228
-
229
- UNION
230
-
231
- SELECT u.name as receiver_name, u.id as receiver_id,
232
- u2.name as sender_name, u2.id as sender_id,
233
- um.content, um.updated_at, um.created_at
234
- FROM users u
235
- INNER JOIN users_messages um ON ( u.id = users_messages.to_id )
236
- INNER JOIN users u2 ON ( u2.id = users_messages.from_id )
237
-
238
- ORDER BY created_at ASC
239
- SQLite3::SQLException: no such table: main.users_messages: CREATE VIEW messages AS
240
- SELECT u2.name as receiver_name, u2.id as receiver_id,
241
- u1.name as sender_name, u1.id as sender_id,
242
- um.content, um.updated_at, um.created_at
243
- FROM users u
244
- INNER JOIN users_messages um ON ( u.id = users_messages.from_id )
245
- INNER JOIN users u2 ON (u2.id = users_messages.to_id)
246
-
247
- UNION
248
-
249
- SELECT u.name as receiver_name, u.id as receiver_id,
250
- u2.name as sender_name, u2.id as sender_id,
251
- um.content, um.updated_at, um.created_at
252
- FROM users u
253
- INNER JOIN users_messages um ON ( u.id = users_messages.to_id )
254
- INNER JOIN users u2 ON ( u2.id = users_messages.from_id )
255
-
256
- ORDER BY created_at ASC
257
-  (0.3ms) DROP VIEW messages
258
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
259
-  (1.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
260
-  (0.1ms) select sqlite_version(*)
261
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
262
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
263
- Migrating to CreateTestTables (20160208084226)
264
-  (0.0ms) begin transaction
265
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime) 
266
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
267
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime, "updated_at" datetime) 
268
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
269
-  (0.1ms)  SELECT sql
270
- FROM sqlite_master
271
- WHERE name='index_user_messages_on_from_id' AND type='index'
272
- UNION ALL
273
- SELECT sql
274
- FROM sqlite_temp_master
275
- WHERE name='index_user_messages_on_from_id' AND type='index'
276
- 
277
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
278
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
279
-  (1.0ms) commit transaction
280
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
281
-  (0.1ms) SELECT sql
282
- FROM sqlite_master
283
- WHERE name='index_user_messages_on_to_id' AND type='index'
284
- UNION ALL
285
- SELECT sql
286
- FROM sqlite_temp_master
287
- WHERE name='index_user_messages_on_to_id' AND type='index'
288
-
289
-  (0.1ms)  SELECT sql
290
- FROM sqlite_master
291
- WHERE name='index_user_messages_on_from_id' AND type='index'
292
- UNION ALL
293
- SELECT sql
294
- FROM sqlite_temp_master
295
- WHERE name='index_user_messages_on_from_id' AND type='index'
296
- 
297
-  (0.1ms) SELECT sql
298
- FROM sqlite_master
299
- WHERE name='index_users_on_name' AND type='index'
300
- UNION ALL
301
- SELECT sql
302
- FROM sqlite_temp_master
303
- WHERE name='index_users_on_name' AND type='index'
304
-
305
-  (0.1ms) CREATE VIEW messages AS
306
- SELECT u2.name as receiver_name, u2.id as receiver_id,
307
- u1.name as sender_name, u1.id as sender_id,
308
- um.content, um.updated_at, um.created_at
309
- FROM users u
310
- INNER JOIN user_messages um ON ( u.id = user_messages.from_id )
311
- INNER JOIN users u2 ON (u2.id = user_messages.to_id)
312
-
313
- UNION
314
- (
315
- SELECT u.name as receiver_name, u.id as receiver_id,
316
- u2.name as sender_name, u2.id as sender_id,
317
- um.content, um.updated_at, um.created_at
318
- FROM users u
319
- INNER JOIN user_messages um ON ( u.id = user_messages.to_id )
320
- INNER JOIN users u2 ON ( u2.id = user_messages.from_id )
321
- )
322
- ORDER BY created_at ASC
323
- SQLite3::SQLException: near "(": syntax error: CREATE VIEW messages AS
324
- SELECT u2.name as receiver_name, u2.id as receiver_id,
325
- u1.name as sender_name, u1.id as sender_id,
326
- um.content, um.updated_at, um.created_at
327
- FROM users u
328
- INNER JOIN user_messages um ON ( u.id = user_messages.from_id )
329
- INNER JOIN users u2 ON (u2.id = user_messages.to_id)
330
-
331
- UNION
332
- (
333
- SELECT u.name as receiver_name, u.id as receiver_id,
334
- u2.name as sender_name, u2.id as sender_id,
335
- um.content, um.updated_at, um.created_at
336
- FROM users u
337
- INNER JOIN user_messages um ON ( u.id = user_messages.to_id )
338
- INNER JOIN users u2 ON ( u2.id = user_messages.from_id )
339
- )
340
- ORDER BY created_at ASC
341
-  (0.3ms) DROP VIEW messages
342
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
343
-  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
344
-  (0.1ms) select sqlite_version(*)
345
-  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
346
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
347
- Migrating to CreateTestTables (20160208084226)
348
-  (0.0ms) begin transaction
349
-  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime) 
350
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
351
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime, "updated_at" datetime) 
352
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
353
-  (0.1ms)  SELECT sql
354
- FROM sqlite_master
355
- WHERE name='index_user_messages_on_from_id' AND type='index'
356
- UNION ALL
357
- SELECT sql
358
- FROM sqlite_temp_master
359
- WHERE name='index_user_messages_on_from_id' AND type='index'
360
- 
361
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
362
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
363
-  (0.8ms) commit transaction
364
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
365
-  (0.1ms) SELECT sql
366
- FROM sqlite_master
367
- WHERE name='index_user_messages_on_to_id' AND type='index'
368
- UNION ALL
369
- SELECT sql
370
- FROM sqlite_temp_master
371
- WHERE name='index_user_messages_on_to_id' AND type='index'
372
-
373
-  (0.1ms)  SELECT sql
374
- FROM sqlite_master
375
- WHERE name='index_user_messages_on_from_id' AND type='index'
376
- UNION ALL
377
- SELECT sql
378
- FROM sqlite_temp_master
379
- WHERE name='index_user_messages_on_from_id' AND type='index'
380
- 
381
-  (0.1ms) SELECT sql
382
- FROM sqlite_master
383
- WHERE name='index_users_on_name' AND type='index'
384
- UNION ALL
385
- SELECT sql
386
- FROM sqlite_temp_master
387
- WHERE name='index_users_on_name' AND type='index'
388
-
389
-  (0.1ms) CREATE VIEW messages AS
390
- SELECT u2.name as receiver_name, u2.id as receiver_id,
391
- u1.name as sender_name, u1.id as sender_id,
392
- um.content, um.updated_at, um.created_at
393
- FROM users u
394
- INNER JOIN user_messages um ON ( u.id = user_messages.from_id )
395
- INNER JOIN users u2 ON (u2.id = user_messages.to_id)
396
-
397
- UNION (
398
- SELECT u.name as receiver_name, u.id as receiver_id,
399
- u2.name as sender_name, u2.id as sender_id,
400
- um.content, um.updated_at, um.created_at
401
- FROM users u
402
- INNER JOIN user_messages um ON ( u.id = user_messages.to_id )
403
- INNER JOIN users u2 ON ( u2.id = user_messages.from_id )
404
- )
405
- ORDER BY created_at ASC
406
- SQLite3::SQLException: near "(": syntax error: CREATE VIEW messages AS
407
- SELECT u2.name as receiver_name, u2.id as receiver_id,
408
- u1.name as sender_name, u1.id as sender_id,
409
- um.content, um.updated_at, um.created_at
410
- FROM users u
411
- INNER JOIN user_messages um ON ( u.id = user_messages.from_id )
412
- INNER JOIN users u2 ON (u2.id = user_messages.to_id)
413
-
414
- UNION (
415
- SELECT u.name as receiver_name, u.id as receiver_id,
416
- u2.name as sender_name, u2.id as sender_id,
417
- um.content, um.updated_at, um.created_at
418
- FROM users u
419
- INNER JOIN user_messages um ON ( u.id = user_messages.to_id )
420
- INNER JOIN users u2 ON ( u2.id = user_messages.from_id )
421
- )
422
- ORDER BY created_at ASC
423
-  (0.4ms) DROP VIEW messages
424
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
425
-  (2.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
426
-  (0.1ms) select sqlite_version(*)
427
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
428
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
429
- Migrating to CreateTestTables (20160208084226)
430
-  (0.1ms) begin transaction
431
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime) 
432
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
433
-  (0.2ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime, "updated_at" datetime) 
434
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
435
-  (0.1ms)  SELECT sql
436
- FROM sqlite_master
437
- WHERE name='index_user_messages_on_from_id' AND type='index'
438
- UNION ALL
439
- SELECT sql
440
- FROM sqlite_temp_master
441
- WHERE name='index_user_messages_on_from_id' AND type='index'
442
- 
443
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
444
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
445
-  (0.8ms) commit transaction
446
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
447
-  (0.1ms) SELECT sql
448
- FROM sqlite_master
449
- WHERE name='index_user_messages_on_to_id' AND type='index'
450
- UNION ALL
451
- SELECT sql
452
- FROM sqlite_temp_master
453
- WHERE name='index_user_messages_on_to_id' AND type='index'
454
-
455
-  (0.1ms)  SELECT sql
456
- FROM sqlite_master
457
- WHERE name='index_user_messages_on_from_id' AND type='index'
458
- UNION ALL
459
- SELECT sql
460
- FROM sqlite_temp_master
461
- WHERE name='index_user_messages_on_from_id' AND type='index'
462
- 
463
-  (0.1ms) SELECT sql
464
- FROM sqlite_master
465
- WHERE name='index_users_on_name' AND type='index'
466
- UNION ALL
467
- SELECT sql
468
- FROM sqlite_temp_master
469
- WHERE name='index_users_on_name' AND type='index'
470
-
471
-  (0.3ms) CREATE VIEW messages AS
472
- SELECT u2.name as receiver_name, u2.id as receiver_id,
473
- u1.name as sender_name, u1.id as sender_id,
474
- um.content, um.updated_at, um.created_at
475
- FROM users u
476
- INNER JOIN user_messages um ON ( u.id = user_messages.from_id )
477
- INNER JOIN users u2 ON (u2.id = user_messages.to_id)
478
- UNION
479
- SELECT u.name as receiver_name, u.id as receiver_id,
480
- u2.name as sender_name, u2.id as sender_id,
481
- um.content, um.updated_at, um.created_at
482
- FROM users u
483
- INNER JOIN user_messages um ON ( u.id = user_messages.to_id )
484
- INNER JOIN users u2 ON ( u2.id = user_messages.from_id )
485
- ORDER BY created_at ASC
486
- SQLite3::SQLException: no such column: user_messages.to_id: CREATE VIEW messages AS
487
- SELECT u2.name as receiver_name, u2.id as receiver_id,
488
- u1.name as sender_name, u1.id as sender_id,
489
- um.content, um.updated_at, um.created_at
490
- FROM users u
491
- INNER JOIN user_messages um ON ( u.id = user_messages.from_id )
492
- INNER JOIN users u2 ON (u2.id = user_messages.to_id)
493
- UNION
494
- SELECT u.name as receiver_name, u.id as receiver_id,
495
- u2.name as sender_name, u2.id as sender_id,
496
- um.content, um.updated_at, um.created_at
497
- FROM users u
498
- INNER JOIN user_messages um ON ( u.id = user_messages.to_id )
499
- INNER JOIN users u2 ON ( u2.id = user_messages.from_id )
500
- ORDER BY created_at ASC
501
-  (0.3ms) DROP VIEW messages
502
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
503
-  (1.5ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
504
-  (0.1ms) select sqlite_version(*)
505
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
506
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
507
- Migrating to CreateTestTables (20160208084226)
508
-  (0.0ms) begin transaction
509
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
510
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
511
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
512
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
513
-  (0.1ms)  SELECT sql
514
- FROM sqlite_master
515
- WHERE name='index_user_messages_on_from_id' AND type='index'
516
- UNION ALL
517
- SELECT sql
518
- FROM sqlite_temp_master
519
- WHERE name='index_user_messages_on_from_id' AND type='index'
520
- 
521
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
522
- SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
523
-  (0.9ms) commit transaction
524
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
525
-  (0.1ms) SELECT sql
526
- FROM sqlite_master
527
- WHERE name='index_user_messages_on_to_id' AND type='index'
528
- UNION ALL
529
- SELECT sql
530
- FROM sqlite_temp_master
531
- WHERE name='index_user_messages_on_to_id' AND type='index'
532
-
533
-  (0.1ms)  SELECT sql
534
- FROM sqlite_master
535
- WHERE name='index_user_messages_on_from_id' AND type='index'
536
- UNION ALL
537
- SELECT sql
538
- FROM sqlite_temp_master
539
- WHERE name='index_user_messages_on_from_id' AND type='index'
540
- 
541
-  (0.1ms) SELECT sql
542
- FROM sqlite_master
543
- WHERE name='index_users_on_name' AND type='index'
544
- UNION ALL
545
- SELECT sql
546
- FROM sqlite_temp_master
547
- WHERE name='index_users_on_name' AND type='index'
548
-
549
-  (0.2ms) CREATE VIEW messages AS
550
- SELECT u2.name as receiver_name, u2.id as receiver_id,
551
- u1.name as sender_name, u1.id as sender_id,
552
- um.content, um.updated_at, um.created_at
553
- FROM users u
554
- INNER JOIN user_messages um ON ( u.id = user_messages.from_id )
555
- INNER JOIN users u2 ON (u2.id = user_messages.to_id)
556
- UNION
557
- SELECT u.name as receiver_name, u.id as receiver_id,
558
- u2.name as sender_name, u2.id as sender_id,
559
- um.content, um.updated_at, um.created_at
560
- FROM users u
561
- INNER JOIN user_messages um ON ( u.id = user_messages.to_id )
562
- INNER JOIN users u2 ON ( u2.id = user_messages.from_id )
563
- ORDER BY created_at ASC
564
- SQLite3::SQLException: no such column: user_messages.to_id: CREATE VIEW messages AS
565
- SELECT u2.name as receiver_name, u2.id as receiver_id,
566
- u1.name as sender_name, u1.id as sender_id,
567
- um.content, um.updated_at, um.created_at
568
- FROM users u
569
- INNER JOIN user_messages um ON ( u.id = user_messages.from_id )
570
- INNER JOIN users u2 ON (u2.id = user_messages.to_id)
571
- UNION
572
- SELECT u.name as receiver_name, u.id as receiver_id,
573
- u2.name as sender_name, u2.id as sender_id,
574
- um.content, um.updated_at, um.created_at
575
- FROM users u
576
- INNER JOIN user_messages um ON ( u.id = user_messages.to_id )
577
- INNER JOIN users u2 ON ( u2.id = user_messages.from_id )
578
- ORDER BY created_at ASC
579
-  (0.3ms) DROP VIEW messages
580
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
581
-  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
582
-  (0.1ms) select sqlite_version(*)
583
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
584
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
585
- Migrating to CreateTestTables (20160208084226)
586
-  (0.0ms) begin transaction
587
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
588
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
589
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
590
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
591
-  (0.1ms)  SELECT sql
592
- FROM sqlite_master
593
- WHERE name='index_user_messages_on_from_id' AND type='index'
594
- UNION ALL
595
- SELECT sql
596
- FROM sqlite_temp_master
597
- WHERE name='index_user_messages_on_from_id' AND type='index'
598
- 
599
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
600
- SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
601
-  (0.8ms) commit transaction
602
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
603
-  (0.1ms) SELECT sql
604
- FROM sqlite_master
605
- WHERE name='index_user_messages_on_to_id' AND type='index'
606
- UNION ALL
607
- SELECT sql
608
- FROM sqlite_temp_master
609
- WHERE name='index_user_messages_on_to_id' AND type='index'
610
-
611
-  (0.1ms)  SELECT sql
612
- FROM sqlite_master
613
- WHERE name='index_user_messages_on_from_id' AND type='index'
614
- UNION ALL
615
- SELECT sql
616
- FROM sqlite_temp_master
617
- WHERE name='index_user_messages_on_from_id' AND type='index'
618
- 
619
-  (0.1ms) SELECT sql
620
- FROM sqlite_master
621
- WHERE name='index_users_on_name' AND type='index'
622
- UNION ALL
623
- SELECT sql
624
- FROM sqlite_temp_master
625
- WHERE name='index_users_on_name' AND type='index'
626
-
627
-  (0.2ms) CREATE VIEW messages AS
628
- SELECT u2.name as receiver_name, u2.id as receiver_id,
629
- u1.name as sender_name, u1.id as sender_id,
630
- um.content, um.updated_at, um.created_at
631
- FROM users u
632
- INNER JOIN user_messages um ON ( u.id = um.from_id )
633
- INNER JOIN users u2 ON (u2.id = um.to_id)
634
- UNION
635
- SELECT u.name as receiver_name, u.id as receiver_id,
636
- u2.name as sender_name, u2.id as sender_id,
637
- um.content, um.updated_at, um.created_at
638
- FROM users u
639
- INNER JOIN user_messages um ON ( u.id = um.to_id )
640
- INNER JOIN users u2 ON ( u2.id = um.from_id )
641
- ORDER BY created_at ASC
642
- SQLite3::SQLException: no such column: u1.name: CREATE VIEW messages AS
643
- SELECT u2.name as receiver_name, u2.id as receiver_id,
644
- u1.name as sender_name, u1.id as sender_id,
645
- um.content, um.updated_at, um.created_at
646
- FROM users u
647
- INNER JOIN user_messages um ON ( u.id = um.from_id )
648
- INNER JOIN users u2 ON (u2.id = um.to_id)
649
- UNION
650
- SELECT u.name as receiver_name, u.id as receiver_id,
651
- u2.name as sender_name, u2.id as sender_id,
652
- um.content, um.updated_at, um.created_at
653
- FROM users u
654
- INNER JOIN user_messages um ON ( u.id = um.to_id )
655
- INNER JOIN users u2 ON ( u2.id = um.from_id )
656
- ORDER BY created_at ASC
657
-  (0.3ms) DROP VIEW messages
658
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
659
-  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
660
-  (0.1ms) select sqlite_version(*)
661
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
662
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
663
- Migrating to CreateTestTables (20160208084226)
664
-  (0.1ms) begin transaction
665
-  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
666
-  (0.2ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
667
-  (0.2ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
668
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
669
-  (0.1ms)  SELECT sql
670
- FROM sqlite_master
671
- WHERE name='index_user_messages_on_from_id' AND type='index'
672
- UNION ALL
673
- SELECT sql
674
- FROM sqlite_temp_master
675
- WHERE name='index_user_messages_on_from_id' AND type='index'
676
- 
677
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
678
- SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
679
-  (0.8ms) commit transaction
680
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
681
-  (0.1ms) SELECT sql
682
- FROM sqlite_master
683
- WHERE name='index_user_messages_on_to_id' AND type='index'
684
- UNION ALL
685
- SELECT sql
686
- FROM sqlite_temp_master
687
- WHERE name='index_user_messages_on_to_id' AND type='index'
688
-
689
-  (0.1ms)  SELECT sql
690
- FROM sqlite_master
691
- WHERE name='index_user_messages_on_from_id' AND type='index'
692
- UNION ALL
693
- SELECT sql
694
- FROM sqlite_temp_master
695
- WHERE name='index_user_messages_on_from_id' AND type='index'
696
- 
697
-  (0.1ms) SELECT sql
698
- FROM sqlite_master
699
- WHERE name='index_users_on_name' AND type='index'
700
- UNION ALL
701
- SELECT sql
702
- FROM sqlite_temp_master
703
- WHERE name='index_users_on_name' AND type='index'
704
-
705
-  (0.2ms) CREATE VIEW messages AS
706
- SELECT u2.name as receiver_name, u2.id as receiver_id,
707
- u1.name as sender_name, u1.id as sender_id,
708
- um.content, um.updated_at, um.created_at
709
- FROM users u1
710
- INNER JOIN user_messages um ON ( u.id = um.from_id )
711
- INNER JOIN users u2 ON (u2.id = um.to_id)
712
- UNION
713
- SELECT u1.name as receiver_name, u1.id as receiver_id,
714
- u2.name as sender_name, u2.id as sender_id,
715
- um.content, um.updated_at, um.created_at
716
- FROM users u1
717
- INNER JOIN user_messages um ON ( u.id = um.to_id )
718
- INNER JOIN users u2 ON ( u2.id = um.from_id )
719
- ORDER BY created_at ASC
720
- SQLite3::SQLException: no such column: u.id: CREATE VIEW messages AS
721
- SELECT u2.name as receiver_name, u2.id as receiver_id,
722
- u1.name as sender_name, u1.id as sender_id,
723
- um.content, um.updated_at, um.created_at
724
- FROM users u1
725
- INNER JOIN user_messages um ON ( u.id = um.from_id )
726
- INNER JOIN users u2 ON (u2.id = um.to_id)
727
- UNION
728
- SELECT u1.name as receiver_name, u1.id as receiver_id,
729
- u2.name as sender_name, u2.id as sender_id,
730
- um.content, um.updated_at, um.created_at
731
- FROM users u1
732
- INNER JOIN user_messages um ON ( u.id = um.to_id )
733
- INNER JOIN users u2 ON ( u2.id = um.from_id )
734
- ORDER BY created_at ASC
735
-  (0.3ms) DROP VIEW messages
736
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
737
-  (1.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
738
-  (0.1ms) select sqlite_version(*)
739
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
740
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
741
- Migrating to CreateTestTables (20160208084226)
742
-  (0.0ms) begin transaction
743
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
744
-  (0.3ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
745
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
746
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
747
-  (0.1ms)  SELECT sql
748
- FROM sqlite_master
749
- WHERE name='index_user_messages_on_from_id' AND type='index'
750
- UNION ALL
751
- SELECT sql
752
- FROM sqlite_temp_master
753
- WHERE name='index_user_messages_on_from_id' AND type='index'
754
- 
755
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
756
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
757
-  (0.8ms) commit transaction
758
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
759
-  (0.1ms) SELECT sql
760
- FROM sqlite_master
761
- WHERE name='index_user_messages_on_to_id' AND type='index'
762
- UNION ALL
763
- SELECT sql
764
- FROM sqlite_temp_master
765
- WHERE name='index_user_messages_on_to_id' AND type='index'
766
-
767
-  (0.1ms)  SELECT sql
768
- FROM sqlite_master
769
- WHERE name='index_user_messages_on_from_id' AND type='index'
770
- UNION ALL
771
- SELECT sql
772
- FROM sqlite_temp_master
773
- WHERE name='index_user_messages_on_from_id' AND type='index'
774
- 
775
-  (0.1ms) SELECT sql
776
- FROM sqlite_master
777
- WHERE name='index_users_on_name' AND type='index'
778
- UNION ALL
779
- SELECT sql
780
- FROM sqlite_temp_master
781
- WHERE name='index_users_on_name' AND type='index'
782
-
783
-  (0.2ms) CREATE VIEW messages AS
784
- SELECT u2.name as receiver_name, u2.id as receiver_id,
785
- u1.name as sender_name, u1.id as sender_id,
786
- um.content, um.updated_at, um.created_at
787
- FROM users u1
788
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
789
- INNER JOIN users u2 ON (u2.id = um.to_id)
790
- UNION
791
- SELECT u1.name as receiver_name, u1.id as receiver_id,
792
- u2.name as sender_name, u2.id as sender_id,
793
- um.content, um.updated_at, um.created_at
794
- FROM users u1
795
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
796
- INNER JOIN users u2 ON ( u2.id = um.from_id )
797
- ORDER BY created_at ASC
798
- SQLite3::SQLException: 1st ORDER BY term does not match any column in the result set: CREATE VIEW messages AS
799
- SELECT u2.name as receiver_name, u2.id as receiver_id,
800
- u1.name as sender_name, u1.id as sender_id,
801
- um.content, um.updated_at, um.created_at
802
- FROM users u1
803
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
804
- INNER JOIN users u2 ON (u2.id = um.to_id)
805
- UNION
806
- SELECT u1.name as receiver_name, u1.id as receiver_id,
807
- u2.name as sender_name, u2.id as sender_id,
808
- um.content, um.updated_at, um.created_at
809
- FROM users u1
810
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
811
- INNER JOIN users u2 ON ( u2.id = um.from_id )
812
- ORDER BY created_at ASC
813
-  (0.3ms) DROP VIEW messages
814
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
815
-  (2.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
816
-  (0.1ms) select sqlite_version(*)
817
-  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
818
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
819
- Migrating to CreateTestTables (20160208084226)
820
-  (0.0ms) begin transaction
821
-  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
822
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
823
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
824
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
825
-  (0.1ms)  SELECT sql
826
- FROM sqlite_master
827
- WHERE name='index_user_messages_on_from_id' AND type='index'
828
- UNION ALL
829
- SELECT sql
830
- FROM sqlite_temp_master
831
- WHERE name='index_user_messages_on_from_id' AND type='index'
832
- 
833
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
834
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
835
-  (0.7ms) commit transaction
836
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
837
-  (0.1ms) SELECT sql
838
- FROM sqlite_master
839
- WHERE name='index_user_messages_on_to_id' AND type='index'
840
- UNION ALL
841
- SELECT sql
842
- FROM sqlite_temp_master
843
- WHERE name='index_user_messages_on_to_id' AND type='index'
844
-
845
-  (0.1ms)  SELECT sql
846
- FROM sqlite_master
847
- WHERE name='index_user_messages_on_from_id' AND type='index'
848
- UNION ALL
849
- SELECT sql
850
- FROM sqlite_temp_master
851
- WHERE name='index_user_messages_on_from_id' AND type='index'
852
- 
853
-  (0.1ms) SELECT sql
854
- FROM sqlite_master
855
- WHERE name='index_users_on_name' AND type='index'
856
- UNION ALL
857
- SELECT sql
858
- FROM sqlite_temp_master
859
- WHERE name='index_users_on_name' AND type='index'
860
-
861
-  (0.9ms) CREATE VIEW messages AS
862
- SELECT u2.name as receiver_name, u2.id as receiver_id,
863
- u1.name as sender_name, u1.id as sender_id,
864
- um.content, um.updated_at, um.created_at
865
- FROM users u1
866
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
867
- INNER JOIN users u2 ON (u2.id = um.to_id)
868
- UNION
869
- SELECT u1.name as receiver_name, u1.id as receiver_id,
870
- u2.name as sender_name, u2.id as sender_id,
871
- um.content, um.updated_at, um.created_at
872
- FROM users u1
873
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
874
- INNER JOIN users u2 ON ( u2.id = um.from_id )
875
- ORDER BY um.created_at ASC
876
-  (0.3ms) DROP VIEW chats
877
- SQLite3::SQLException: no such view: chats: DROP VIEW chats
878
-  (0.2ms) DROP VIEW messages
879
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
880
-  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
881
-  (0.1ms) select sqlite_version(*)
882
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
883
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
884
- Migrating to CreateTestTables (20160208084226)
885
-  (0.1ms) begin transaction
886
-  (0.2ms) CREATE EXTENSION intarray;
887
- SQLite3::SQLException: near "EXTENSION": syntax error: CREATE EXTENSION intarray;
888
-  (0.0ms) rollback transaction
889
-  (0.3ms) DROP VIEW chats
890
- SQLite3::SQLException: no such view: chats: DROP VIEW chats
891
-  (0.1ms) DROP VIEW messages
892
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
893
-  (1.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
894
-  (0.1ms) select sqlite_version(*)
895
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
896
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
897
- Migrating to CreateTestTables (20160208084226)
898
-  (0.1ms) begin transaction
899
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
900
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
901
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
902
-  (0.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
903
-  (0.1ms) SELECT sql
904
- FROM sqlite_master
905
- WHERE name='index_user_messages_on_from_id' AND type='index'
906
- UNION ALL
907
- SELECT sql
908
- FROM sqlite_temp_master
909
- WHERE name='index_user_messages_on_from_id' AND type='index'
910
-
911
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
912
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
913
-  (0.7ms) commit transaction
914
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
915
-  (0.1ms)  SELECT sql
916
- FROM sqlite_master
917
- WHERE name='index_user_messages_on_to_id' AND type='index'
918
- UNION ALL
919
- SELECT sql
920
- FROM sqlite_temp_master
921
- WHERE name='index_user_messages_on_to_id' AND type='index'
922
- 
923
-  (0.1ms) SELECT sql
924
- FROM sqlite_master
925
- WHERE name='index_user_messages_on_from_id' AND type='index'
926
- UNION ALL
927
- SELECT sql
928
- FROM sqlite_temp_master
929
- WHERE name='index_user_messages_on_from_id' AND type='index'
930
-
931
-  (0.1ms)  SELECT sql
932
- FROM sqlite_master
933
- WHERE name='index_users_on_name' AND type='index'
934
- UNION ALL
935
- SELECT sql
936
- FROM sqlite_temp_master
937
- WHERE name='index_users_on_name' AND type='index'
938
- 
939
-  (1.4ms) CREATE VIEW messages AS SELECT DISTINCT receiver_name, receiver_id, sender_name, sender_id, content, updated_at, created_at
940
- FROM
941
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
942
- u1.name as sender_name, u1.id as sender_id,
943
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
944
- FROM users u1
945
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
946
- INNER JOIN users u2 ON (u2.id = um.to_id)
947
- UNION
948
- SELECT u1.name as receiver_name, u1.id as receiver_id,
949
- u2.name as sender_name, u2.id as sender_id,
950
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
951
- FROM users u1
952
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
953
- INNER JOIN users u2 ON ( u2.id = um.from_id )
954
- ORDER BY um.created_at ASC
955
- )
956
-  (0.1ms) CREATE VIEW chats AS SELECT SORT(ARRAY[sender_id, receiver_id])::text AS id,
957
- sender_name, receiver_name, MAX(updated_at), COUNT(*) as number_of_messages
958
- GROUP BY SORT(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
959
- FROM messages
960
- SQLite3::SQLException: near "[sender_id, receiver_id]": syntax error: CREATE VIEW chats AS SELECT SORT(ARRAY[sender_id, receiver_id])::text AS id,
961
- sender_name, receiver_name, MAX(updated_at), COUNT(*) as number_of_messages
962
- GROUP BY SORT(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
963
- FROM messages
964
-  (0.3ms) DROP VIEW chats
965
- SQLite3::SQLException: no such view: chats: DROP VIEW chats
966
-  (0.1ms) DROP VIEW messages
967
- SQLite3::SQLException: no such view: messages: DROP VIEW messages
968
-  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
969
-  (0.1ms) select sqlite_version(*)
970
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
971
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
972
- Migrating to CreateTestTables (20160208084226)
973
-  (0.1ms) begin transaction
974
-  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
975
-  (0.1ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
976
-  (0.1ms) CREATE TABLE "user_messages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_id" integer, "to_id" integer, "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
977
-  (0.2ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
978
-  (0.1ms) SELECT sql
979
- FROM sqlite_master
980
- WHERE name='index_user_messages_on_from_id' AND type='index'
981
- UNION ALL
982
- SELECT sql
983
- FROM sqlite_temp_master
984
- WHERE name='index_user_messages_on_from_id' AND type='index'
985
-
986
-  (0.1ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
987
- SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160208084226"]]
988
-  (2.6ms) commit transaction
989
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
990
-  (0.1ms)  SELECT sql
991
- FROM sqlite_master
992
- WHERE name='index_user_messages_on_to_id' AND type='index'
993
- UNION ALL
994
- SELECT sql
995
- FROM sqlite_temp_master
996
- WHERE name='index_user_messages_on_to_id' AND type='index'
997
- 
998
-  (0.1ms) SELECT sql
999
- FROM sqlite_master
1000
- WHERE name='index_user_messages_on_from_id' AND type='index'
1001
- UNION ALL
1002
- SELECT sql
1003
- FROM sqlite_temp_master
1004
- WHERE name='index_user_messages_on_from_id' AND type='index'
1005
-
1006
-  (0.1ms)  SELECT sql
1007
- FROM sqlite_master
1008
- WHERE name='index_users_on_name' AND type='index'
1009
- UNION ALL
1010
- SELECT sql
1011
- FROM sqlite_temp_master
1012
- WHERE name='index_users_on_name' AND type='index'
1013
- 
1014
-  (0.9ms) CREATE VIEW messages AS SELECT DISTINCT receiver_name, receiver_id, sender_name, sender_id, content, updated_at, created_at
1015
- FROM
1016
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1017
- u1.name as sender_name, u1.id as sender_id,
1018
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1019
- FROM users u1
1020
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1021
- INNER JOIN users u2 ON (u2.id = um.to_id)
1022
- UNION
1023
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1024
- u2.name as sender_name, u2.id as sender_id,
1025
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1026
- FROM users u1
1027
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1028
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1029
- ORDER BY um.created_at ASC
1030
- )
1031
-  (0.2ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS id,
1032
- sender_name, receiver_name, MIN(created_at) as created_at,
1033
- MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1034
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
1035
- FROM messages
1036
- SQLite3::SQLException: near "[sender_id, receiver_id]": syntax error: CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS id,
1037
- sender_name, receiver_name, MIN(created_at) as created_at,
1038
- MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1039
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
1040
- FROM messages
1041
-  (9.4ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1042
- BEGIN
1043
- RETURN x + y;
1044
- END;
1045
- $$ LANGUAGE plpgsql;
1046
-  (1.1ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1047
- BEGIN
1048
- IF x[0] > x[1]
1049
- RETURN ARRAY[x[1], x[0]];
1050
- ELSE
1051
- RETURN x
1052
- END
1053
- END;
1054
- $$ LANGUAGE plpgsql;
1055
- PG::SyntaxError: ERROR: missing "THEN" at end of SQL expression
1056
- LINE 4: RETURN ARRAY[x[1], x[0]];
1057
- ^
1058
- : CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1059
- BEGIN
1060
- IF x[0] > x[1]
1061
- RETURN ARRAY[x[1], x[0]];
1062
- ELSE
1063
- RETURN x
1064
- END
1065
- END;
1066
- $$ LANGUAGE plpgsql;
1067
-  (1.9ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1068
- BEGIN
1069
- RETURN x + y;
1070
- END;
1071
- $$ LANGUAGE plpgsql;
1072
-  (0.5ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1073
- BEGIN
1074
- IF x[0] > x[1] THEN
1075
- RETURN ARRAY[x[1], x[0]];
1076
- ELSE
1077
- RETURN x
1078
- END
1079
- END;
1080
- $$ LANGUAGE plpgsql;
1081
- PG::SyntaxError: ERROR: syntax error at or near "END"
1082
- LINE 7: END
1083
- ^
1084
- : CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1085
- BEGIN
1086
- IF x[0] > x[1] THEN
1087
- RETURN ARRAY[x[1], x[0]];
1088
- ELSE
1089
- RETURN x
1090
- END
1091
- END;
1092
- $$ LANGUAGE plpgsql;
1093
-  (1.8ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1094
- BEGIN
1095
- RETURN x + y;
1096
- END;
1097
- $$ LANGUAGE plpgsql;
1098
-  (0.5ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1099
- BEGIN
1100
- IF x[0] > x[1] THEN
1101
- RETURN ARRAY[x[1], x[0]];
1102
- ELSE
1103
- RETURN x;
1104
- END;
1105
- END;
1106
- $$ LANGUAGE plpgsql;
1107
- PG::SyntaxError: ERROR: syntax error at or near ";"
1108
- LINE 7: END;
1109
- ^
1110
- : CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1111
- BEGIN
1112
- IF x[0] > x[1] THEN
1113
- RETURN ARRAY[x[1], x[0]];
1114
- ELSE
1115
- RETURN x;
1116
- END;
1117
- END;
1118
- $$ LANGUAGE plpgsql;
1119
-  (2.1ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1120
- BEGIN
1121
- RETURN x + y;
1122
- END;
1123
- $$ LANGUAGE plpgsql;
1124
-  (0.7ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1125
- BEGIN
1126
- IF x[0] > x[1] THEN
1127
- RETURN ARRAY[x[1], x[0]];
1128
- ELSE
1129
- RETURN x;
1130
- END
1131
- END;
1132
- $$ LANGUAGE plpgsql;
1133
- PG::SyntaxError: ERROR: syntax error at or near "END"
1134
- LINE 8: END;
1135
- ^
1136
- : CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1137
- BEGIN
1138
- IF x[0] > x[1] THEN
1139
- RETURN ARRAY[x[1], x[0]];
1140
- ELSE
1141
- RETURN x;
1142
- END
1143
- END;
1144
- $$ LANGUAGE plpgsql;
1145
-  (1.9ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1146
- BEGIN
1147
- RETURN x + y;
1148
- END;
1149
- $$ LANGUAGE plpgsql;
1150
-  (0.5ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1151
- BEGIN
1152
- IF x[0] > x[1] THEN
1153
- RETURN ARRAY[x[1], x[0]];
1154
- ELSE
1155
- RETURN x;
1156
- END IF;
1157
- END;
1158
- $$ LANGUAGE plpgsql;
1159
-  (1.3ms) DROP VIEW chats
1160
- PG::UndefinedTable: ERROR: view "chats" does not exist
1161
- : DROP VIEW chats
1162
-  (0.2ms) DROP VIEW messages
1163
- PG::UndefinedTable: ERROR: view "messages" does not exist
1164
- : DROP VIEW messages
1165
-  (7.3ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1166
-  (5.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1167
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1168
- Migrating to CreateTestTables (20160208084226)
1169
-  (0.1ms) BEGIN
1170
-  (3.8ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1171
-  (0.9ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1172
-  (2.4ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1173
-  (0.6ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1174
-  (0.9ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1175
- SQL (1.0ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1176
-  (0.3ms) COMMIT
1177
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1178
-  (2.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
1179
- FROM pg_constraint c
1180
- JOIN pg_class t1 ON c.conrelid = t1.oid
1181
- JOIN pg_class t2 ON c.confrelid = t2.oid
1182
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1183
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1184
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1185
- WHERE c.contype = 'f'
1186
- AND t1.relname = 'user_messages'
1187
- AND t3.nspname = ANY (current_schemas(false))
1188
- ORDER BY c.conname
1189
- 
1190
-  (1.7ms) 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
1191
- FROM pg_constraint c
1192
- JOIN pg_class t1 ON c.conrelid = t1.oid
1193
- JOIN pg_class t2 ON c.confrelid = t2.oid
1194
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1195
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1196
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1197
- WHERE c.contype = 'f'
1198
- AND t1.relname = 'users'
1199
- AND t3.nspname = ANY (current_schemas(false))
1200
- ORDER BY c.conname
1201
-
1202
-  (0.3ms) CREATE VIEW messages AS SELECT DISTINCT receiver_name, receiver_id, sender_name, sender_id, content, updated_at, created_at
1203
- FROM
1204
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1205
- u1.name as sender_name, u1.id as sender_id,
1206
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1207
- FROM users u1
1208
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1209
- INNER JOIN users u2 ON (u2.id = um.to_id)
1210
- UNION
1211
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1212
- u2.name as sender_name, u2.id as sender_id,
1213
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1214
- FROM users u1
1215
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1216
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1217
- ORDER BY um.created_at ASC
1218
- )
1219
- PG::SyntaxError: ERROR: subquery in FROM must have an alias
1220
- LINE 3: (SELECT u2.name as receiver_name, u2.id as receiver_id,
1221
- ^
1222
- HINT: For example, FROM (SELECT ...) [AS] foo.
1223
- : CREATE VIEW messages AS SELECT DISTINCT receiver_name, receiver_id, sender_name, sender_id, content, updated_at, created_at
1224
- FROM
1225
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1226
- u1.name as sender_name, u1.id as sender_id,
1227
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1228
- FROM users u1
1229
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1230
- INNER JOIN users u2 ON (u2.id = um.to_id)
1231
- UNION
1232
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1233
- u2.name as sender_name, u2.id as sender_id,
1234
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1235
- FROM users u1
1236
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1237
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1238
- ORDER BY um.created_at ASC
1239
- )
1240
-  (2.1ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1241
- BEGIN
1242
- RETURN x + y;
1243
- END;
1244
- $$ LANGUAGE plpgsql;
1245
-  (0.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1246
- BEGIN
1247
- IF x[0] > x[1] THEN
1248
- RETURN ARRAY[x[1], x[0]];
1249
- ELSE
1250
- RETURN x;
1251
- END IF;
1252
- END;
1253
- $$ LANGUAGE plpgsql;
1254
-  (0.3ms) DROP VIEW chats
1255
- PG::UndefinedTable: ERROR: view "chats" does not exist
1256
- : DROP VIEW chats
1257
-  (0.2ms) DROP VIEW messages
1258
- PG::UndefinedTable: ERROR: view "messages" does not exist
1259
- : DROP VIEW messages
1260
-  (2.3ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1261
-  (0.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1262
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1263
- Migrating to CreateTestTables (20160208084226)
1264
-  (0.1ms) BEGIN
1265
-  (3.0ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1266
-  (0.7ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1267
-  (2.3ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1268
-  (0.6ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1269
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1270
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1271
-  (0.6ms) COMMIT
1272
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1273
-  (1.8ms) 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
1274
- FROM pg_constraint c
1275
- JOIN pg_class t1 ON c.conrelid = t1.oid
1276
- JOIN pg_class t2 ON c.confrelid = t2.oid
1277
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1278
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1279
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1280
- WHERE c.contype = 'f'
1281
- AND t1.relname = 'user_messages'
1282
- AND t3.nspname = ANY (current_schemas(false))
1283
- ORDER BY c.conname
1284
- 
1285
-  (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
1286
- FROM pg_constraint c
1287
- JOIN pg_class t1 ON c.conrelid = t1.oid
1288
- JOIN pg_class t2 ON c.confrelid = t2.oid
1289
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1290
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1291
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1292
- WHERE c.contype = 'f'
1293
- AND t1.relname = 'users'
1294
- AND t3.nspname = ANY (current_schemas(false))
1295
- ORDER BY c.conname
1296
-
1297
-  (0.6ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1298
- FROM
1299
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1300
- u1.name as sender_name, u1.id as sender_id,
1301
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1302
- FROM users u1
1303
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1304
- INNER JOIN users u2 ON (u2.id = um.to_id)
1305
- UNION
1306
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1307
- u2.name as sender_name, u2.id as sender_id,
1308
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1309
- FROM users u1
1310
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1311
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1312
- ORDER BY um.created_at ASC
1313
- ) AS _
1314
- PG::UndefinedTable: ERROR: missing FROM-clause entry for table "um"
1315
- LINE 16: ORDER BY um.created_at ASC
1316
- ^
1317
- : CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1318
- FROM
1319
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1320
- u1.name as sender_name, u1.id as sender_id,
1321
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1322
- FROM users u1
1323
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1324
- INNER JOIN users u2 ON (u2.id = um.to_id)
1325
- UNION
1326
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1327
- u2.name as sender_name, u2.id as sender_id,
1328
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1329
- FROM users u1
1330
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1331
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1332
- ORDER BY um.created_at ASC
1333
- ) AS _
1334
-  (1.9ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1335
- BEGIN
1336
- RETURN x + y;
1337
- END;
1338
- $$ LANGUAGE plpgsql;
1339
-  (0.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1340
- BEGIN
1341
- IF x[0] > x[1] THEN
1342
- RETURN ARRAY[x[1], x[0]];
1343
- ELSE
1344
- RETURN x;
1345
- END IF;
1346
- END;
1347
- $$ LANGUAGE plpgsql;
1348
-  (0.4ms) DROP VIEW chats
1349
- PG::UndefinedTable: ERROR: view "chats" does not exist
1350
- : DROP VIEW chats
1351
-  (0.2ms) DROP VIEW messages
1352
- PG::UndefinedTable: ERROR: view "messages" does not exist
1353
- : DROP VIEW messages
1354
-  (2.3ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1355
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1356
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1357
- Migrating to CreateTestTables (20160208084226)
1358
-  (0.1ms) BEGIN
1359
-  (6.4ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1360
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1361
-  (2.2ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1362
-  (0.5ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1363
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1364
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1365
-  (0.6ms) COMMIT
1366
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1367
-  (2.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
1368
- FROM pg_constraint c
1369
- JOIN pg_class t1 ON c.conrelid = t1.oid
1370
- JOIN pg_class t2 ON c.confrelid = t2.oid
1371
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1372
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1373
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1374
- WHERE c.contype = 'f'
1375
- AND t1.relname = 'user_messages'
1376
- AND t3.nspname = ANY (current_schemas(false))
1377
- ORDER BY c.conname
1378
- 
1379
-  (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
1380
- FROM pg_constraint c
1381
- JOIN pg_class t1 ON c.conrelid = t1.oid
1382
- JOIN pg_class t2 ON c.confrelid = t2.oid
1383
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1384
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1385
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1386
- WHERE c.contype = 'f'
1387
- AND t1.relname = 'users'
1388
- AND t3.nspname = ANY (current_schemas(false))
1389
- ORDER BY c.conname
1390
-
1391
-  (7.5ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1392
- FROM
1393
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1394
- u1.name as sender_name, u1.id as sender_id,
1395
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1396
- FROM users u1
1397
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1398
- INNER JOIN users u2 ON (u2.id = um.to_id)
1399
- UNION
1400
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1401
- u2.name as sender_name, u2.id as sender_id,
1402
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1403
- FROM users u1
1404
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1405
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1406
- ORDER BY created_at ASC
1407
- ) AS _
1408
-  (0.3ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS id,
1409
- sender_name, receiver_name, MIN(created_at) as created_at,
1410
- MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1411
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
1412
- FROM messages
1413
- PG::SyntaxError: ERROR: syntax error at or near "FROM"
1414
- LINE 5: FROM messages
1415
- ^
1416
- : CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS id,
1417
- sender_name, receiver_name, MIN(created_at) as created_at,
1418
- MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1419
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
1420
- FROM messages
1421
-  (2.2ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1422
- BEGIN
1423
- RETURN x + y;
1424
- END;
1425
- $$ LANGUAGE plpgsql;
1426
-  (0.7ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1427
- BEGIN
1428
- IF x[0] > x[1] THEN
1429
- RETURN ARRAY[x[1], x[0]];
1430
- ELSE
1431
- RETURN x;
1432
- END IF;
1433
- END;
1434
- $$ LANGUAGE plpgsql;
1435
-  (0.4ms) DROP VIEW chats
1436
- PG::UndefinedTable: ERROR: view "chats" does not exist
1437
- : DROP VIEW chats
1438
-  (0.2ms) DROP VIEW messages
1439
- PG::UndefinedTable: ERROR: view "messages" does not exist
1440
- : DROP VIEW messages
1441
-  (2.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1442
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1443
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1444
- Migrating to CreateTestTables (20160208084226)
1445
-  (0.1ms) BEGIN
1446
-  (2.8ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1447
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1448
-  (2.2ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1449
-  (0.7ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1450
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1451
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1452
-  (0.8ms) COMMIT
1453
- ActiveRecord::SchemaMigration Load (0.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
1454
-  (2.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
1455
- FROM pg_constraint c
1456
- JOIN pg_class t1 ON c.conrelid = t1.oid
1457
- JOIN pg_class t2 ON c.confrelid = t2.oid
1458
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1459
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1460
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1461
- WHERE c.contype = 'f'
1462
- AND t1.relname = 'user_messages'
1463
- AND t3.nspname = ANY (current_schemas(false))
1464
- ORDER BY c.conname
1465
- 
1466
-  (1.7ms) 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
1467
- FROM pg_constraint c
1468
- JOIN pg_class t1 ON c.conrelid = t1.oid
1469
- JOIN pg_class t2 ON c.confrelid = t2.oid
1470
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1471
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1472
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1473
- WHERE c.contype = 'f'
1474
- AND t1.relname = 'users'
1475
- AND t3.nspname = ANY (current_schemas(false))
1476
- ORDER BY c.conname
1477
-
1478
-  (0.6ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1479
- FROM
1480
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1481
- u1.name as sender_name, u1.id as sender_id,
1482
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1483
- FROM users u1
1484
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1485
- INNER JOIN users u2 ON (u2.id = um.to_id)
1486
- UNION
1487
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1488
- u2.name as sender_name, u2.id as sender_id,
1489
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1490
- FROM users u1
1491
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1492
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1493
- ORDER BY _.created_at ASC
1494
- ) AS _
1495
- PG::UndefinedTable: ERROR: missing FROM-clause entry for table "_"
1496
- LINE 16: ORDER BY _.created_at ASC
1497
- ^
1498
- : CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1499
- FROM
1500
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1501
- u1.name as sender_name, u1.id as sender_id,
1502
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1503
- FROM users u1
1504
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1505
- INNER JOIN users u2 ON (u2.id = um.to_id)
1506
- UNION
1507
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1508
- u2.name as sender_name, u2.id as sender_id,
1509
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1510
- FROM users u1
1511
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1512
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1513
- ORDER BY _.created_at ASC
1514
- ) AS _
1515
-  (2.7ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1516
- BEGIN
1517
- RETURN x + y;
1518
- END;
1519
- $$ LANGUAGE plpgsql;
1520
-  (0.5ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1521
- BEGIN
1522
- IF x[0] > x[1] THEN
1523
- RETURN ARRAY[x[1], x[0]];
1524
- ELSE
1525
- RETURN x;
1526
- END IF;
1527
- END;
1528
- $$ LANGUAGE plpgsql;
1529
-  (0.4ms) DROP VIEW chats
1530
- PG::UndefinedTable: ERROR: view "chats" does not exist
1531
- : DROP VIEW chats
1532
-  (0.2ms) DROP VIEW messages
1533
- PG::UndefinedTable: ERROR: view "messages" does not exist
1534
- : DROP VIEW messages
1535
-  (2.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1536
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1537
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
1538
- Migrating to CreateTestTables (20160208084226)
1539
-  (0.1ms) BEGIN
1540
-  (5.6ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1541
-  (0.7ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1542
-  (2.4ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1543
-  (0.7ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1544
-  (0.6ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1545
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1546
-  (0.6ms) COMMIT
1547
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1548
-  (1.9ms) 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
1549
- FROM pg_constraint c
1550
- JOIN pg_class t1 ON c.conrelid = t1.oid
1551
- JOIN pg_class t2 ON c.confrelid = t2.oid
1552
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1553
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1554
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1555
- WHERE c.contype = 'f'
1556
- AND t1.relname = 'user_messages'
1557
- AND t3.nspname = ANY (current_schemas(false))
1558
- ORDER BY c.conname
1559
- 
1560
-  (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
1561
- FROM pg_constraint c
1562
- JOIN pg_class t1 ON c.conrelid = t1.oid
1563
- JOIN pg_class t2 ON c.confrelid = t2.oid
1564
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1565
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1566
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1567
- WHERE c.contype = 'f'
1568
- AND t1.relname = 'users'
1569
- AND t3.nspname = ANY (current_schemas(false))
1570
- ORDER BY c.conname
1571
-
1572
-  (7.6ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1573
- FROM
1574
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1575
- u1.name as sender_name, u1.id as sender_id,
1576
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1577
- FROM users u1
1578
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1579
- INNER JOIN users u2 ON (u2.id = um.to_id)
1580
- UNION
1581
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1582
- u2.name as sender_name, u2.id as sender_id,
1583
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1584
- FROM users u1
1585
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1586
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1587
- ORDER BY created_at ASC
1588
- ) AS _
1589
-  (0.3ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS id,
1590
- sender_name, receiver_name, MIN(created_at) as created_at,
1591
- MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1592
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
1593
- FROM messages
1594
- PG::SyntaxError: ERROR: syntax error at or near "FROM"
1595
- LINE 5: FROM messages
1596
- ^
1597
- : CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS id,
1598
- sender_name, receiver_name, MIN(created_at) as created_at,
1599
- MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1600
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
1601
- FROM messages
1602
-  (2.1ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1603
- BEGIN
1604
- RETURN x + y;
1605
- END;
1606
- $$ LANGUAGE plpgsql;
1607
-  (0.5ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1608
- BEGIN
1609
- IF x[0] > x[1] THEN
1610
- RETURN ARRAY[x[1], x[0]];
1611
- ELSE
1612
- RETURN x;
1613
- END IF;
1614
- END;
1615
- $$ LANGUAGE plpgsql;
1616
-  (0.3ms) DROP VIEW chats
1617
- PG::UndefinedTable: ERROR: view "chats" does not exist
1618
- : DROP VIEW chats
1619
-  (0.2ms) DROP VIEW messages
1620
- PG::UndefinedTable: ERROR: view "messages" does not exist
1621
- : DROP VIEW messages
1622
-  (2.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1623
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1624
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1625
- Migrating to CreateTestTables (20160208084226)
1626
-  (0.1ms) BEGIN
1627
-  (5.9ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1628
-  (0.7ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1629
-  (2.4ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1630
-  (0.7ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1631
-  (0.6ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1632
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1633
-  (0.5ms) COMMIT
1634
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1635
-  (1.7ms) 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
1636
- FROM pg_constraint c
1637
- JOIN pg_class t1 ON c.conrelid = t1.oid
1638
- JOIN pg_class t2 ON c.confrelid = t2.oid
1639
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1640
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1641
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1642
- WHERE c.contype = 'f'
1643
- AND t1.relname = 'user_messages'
1644
- AND t3.nspname = ANY (current_schemas(false))
1645
- ORDER BY c.conname
1646
- 
1647
-  (1.7ms) 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
1648
- FROM pg_constraint c
1649
- JOIN pg_class t1 ON c.conrelid = t1.oid
1650
- JOIN pg_class t2 ON c.confrelid = t2.oid
1651
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1652
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1653
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1654
- WHERE c.contype = 'f'
1655
- AND t1.relname = 'users'
1656
- AND t3.nspname = ANY (current_schemas(false))
1657
- ORDER BY c.conname
1658
-
1659
-  (7.8ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1660
- FROM
1661
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1662
- u1.name as sender_name, u1.id as sender_id,
1663
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1664
- FROM users u1
1665
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1666
- INNER JOIN users u2 ON (u2.id = um.to_id)
1667
- UNION
1668
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1669
- u2.name as sender_name, u2.id as sender_id,
1670
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1671
- FROM users u1
1672
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1673
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1674
- ORDER BY created_at ASC
1675
- ) AS _
1676
-  (15.1ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS id,
1677
- sender_name, receiver_name, MIN(created_at) as created_at,
1678
- MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1679
- FROM messages
1680
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
1681
-  (1.9ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1682
- BEGIN
1683
- RETURN x + y;
1684
- END;
1685
- $$ LANGUAGE plpgsql;
1686
-  (0.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1687
- BEGIN
1688
- IF x[0] > x[1] THEN
1689
- RETURN ARRAY[x[1], x[0]];
1690
- ELSE
1691
- RETURN x;
1692
- END IF;
1693
- END;
1694
- $$ LANGUAGE plpgsql;
1695
-  (0.4ms) DROP VIEW chats
1696
- PG::UndefinedTable: ERROR: view "chats" does not exist
1697
- : DROP VIEW chats
1698
-  (0.2ms) DROP VIEW messages
1699
- PG::UndefinedTable: ERROR: view "messages" does not exist
1700
- : DROP VIEW messages
1701
-  (2.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1702
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1703
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
1704
- Migrating to CreateTestTables (20160208084226)
1705
-  (0.1ms) BEGIN
1706
-  (6.5ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1707
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1708
-  (2.3ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1709
-  (0.8ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1710
-  (1.3ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1711
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1712
-  (0.6ms) COMMIT
1713
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1714
-  (1.8ms) 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
1715
- FROM pg_constraint c
1716
- JOIN pg_class t1 ON c.conrelid = t1.oid
1717
- JOIN pg_class t2 ON c.confrelid = t2.oid
1718
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1719
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1720
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1721
- WHERE c.contype = 'f'
1722
- AND t1.relname = 'user_messages'
1723
- AND t3.nspname = ANY (current_schemas(false))
1724
- ORDER BY c.conname
1725
- 
1726
-  (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
1727
- FROM pg_constraint c
1728
- JOIN pg_class t1 ON c.conrelid = t1.oid
1729
- JOIN pg_class t2 ON c.confrelid = t2.oid
1730
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1731
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1732
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1733
- WHERE c.contype = 'f'
1734
- AND t1.relname = 'users'
1735
- AND t3.nspname = ANY (current_schemas(false))
1736
- ORDER BY c.conname
1737
-
1738
-  (10.4ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1739
- FROM
1740
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1741
- u1.name as sender_name, u1.id as sender_id,
1742
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1743
- FROM users u1
1744
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1745
- INNER JOIN users u2 ON (u2.id = um.to_id)
1746
- UNION
1747
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1748
- u2.name as sender_name, u2.id as sender_id,
1749
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1750
- FROM users u1
1751
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1752
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1753
- ORDER BY created_at ASC
1754
- ) AS _
1755
-  (9.5ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS id,
1756
- sender_name, receiver_name, MIN(created_at) as created_at,
1757
- MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1758
- FROM messages
1759
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text, sender_name, receiver_name
1760
-  (29.6ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1761
- BEGIN
1762
- RETURN x + y;
1763
- END;
1764
- $$ LANGUAGE plpgsql;
1765
-  (8.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1766
- BEGIN
1767
- IF x[0] > x[1] THEN
1768
- RETURN ARRAY[x[1], x[0]];
1769
- ELSE
1770
- RETURN x;
1771
- END IF;
1772
- END;
1773
- $$ LANGUAGE plpgsql;
1774
-  (0.5ms) DROP VIEW chats
1775
- PG::UndefinedTable: ERROR: view "chats" does not exist
1776
- : DROP VIEW chats
1777
-  (0.3ms) DROP VIEW messages
1778
- PG::UndefinedTable: ERROR: view "messages" does not exist
1779
- : DROP VIEW messages
1780
-  (13.4ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1781
-  (7.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1782
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1783
- Migrating to CreateTestTables (20160208084226)
1784
-  (0.1ms) BEGIN
1785
-  (17.0ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1786
-  (5.9ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1787
-  (5.4ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1788
-  (2.1ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1789
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1790
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1791
-  (5.3ms) COMMIT
1792
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1793
-  (2.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
1794
- FROM pg_constraint c
1795
- JOIN pg_class t1 ON c.conrelid = t1.oid
1796
- JOIN pg_class t2 ON c.confrelid = t2.oid
1797
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1798
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1799
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1800
- WHERE c.contype = 'f'
1801
- AND t1.relname = 'user_messages'
1802
- AND t3.nspname = ANY (current_schemas(false))
1803
- ORDER BY c.conname
1804
- 
1805
-  (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
1806
- FROM pg_constraint c
1807
- JOIN pg_class t1 ON c.conrelid = t1.oid
1808
- JOIN pg_class t2 ON c.confrelid = t2.oid
1809
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1810
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1811
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1812
- WHERE c.contype = 'f'
1813
- AND t1.relname = 'users'
1814
- AND t3.nspname = ANY (current_schemas(false))
1815
- ORDER BY c.conname
1816
-
1817
-  (13.6ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1818
- FROM
1819
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1820
- u1.name as sender_name, u1.id as sender_id,
1821
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1822
- FROM users u1
1823
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1824
- INNER JOIN users u2 ON (u2.id = um.to_id)
1825
- UNION
1826
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1827
- u2.name as sender_name, u2.id as sender_id,
1828
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1829
- FROM users u1
1830
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1831
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1832
- ORDER BY created_at ASC
1833
- ) AS _
1834
-  (7.1ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS ids,
1835
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1836
- FROM messages
1837
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text
1838
-  (2.0ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1839
- BEGIN
1840
- RETURN x + y;
1841
- END;
1842
- $$ LANGUAGE plpgsql;
1843
-  (0.5ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1844
- BEGIN
1845
- IF x[0] > x[1] THEN
1846
- RETURN ARRAY[x[1], x[0]];
1847
- ELSE
1848
- RETURN x;
1849
- END IF;
1850
- END;
1851
- $$ LANGUAGE plpgsql;
1852
-  (0.3ms) DROP VIEW chats
1853
- PG::UndefinedTable: ERROR: view "chats" does not exist
1854
- : DROP VIEW chats
1855
-  (0.2ms) DROP VIEW messages
1856
- PG::UndefinedTable: ERROR: view "messages" does not exist
1857
- : DROP VIEW messages
1858
-  (2.1ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1859
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1860
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1861
- Migrating to CreateTestTables (20160208084226)
1862
-  (0.1ms) BEGIN
1863
-  (5.9ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1864
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1865
-  (2.2ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1866
-  (0.6ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1867
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1868
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1869
-  (0.6ms) COMMIT
1870
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1871
-  (2.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
1872
- FROM pg_constraint c
1873
- JOIN pg_class t1 ON c.conrelid = t1.oid
1874
- JOIN pg_class t2 ON c.confrelid = t2.oid
1875
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1876
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1877
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1878
- WHERE c.contype = 'f'
1879
- AND t1.relname = 'user_messages'
1880
- AND t3.nspname = ANY (current_schemas(false))
1881
- ORDER BY c.conname
1882
- 
1883
-  (2.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
1884
- FROM pg_constraint c
1885
- JOIN pg_class t1 ON c.conrelid = t1.oid
1886
- JOIN pg_class t2 ON c.confrelid = t2.oid
1887
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1888
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1889
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1890
- WHERE c.contype = 'f'
1891
- AND t1.relname = 'users'
1892
- AND t3.nspname = ANY (current_schemas(false))
1893
- ORDER BY c.conname
1894
-
1895
-  (8.0ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1896
- FROM
1897
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1898
- u1.name as sender_name, u1.id as sender_id,
1899
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1900
- FROM users u1
1901
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1902
- INNER JOIN users u2 ON (u2.id = um.to_id)
1903
- UNION
1904
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1905
- u2.name as sender_name, u2.id as sender_id,
1906
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1907
- FROM users u1
1908
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1909
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1910
- ORDER BY created_at ASC
1911
- ) AS _
1912
-  (13.8ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS ids,
1913
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1914
- FROM messages
1915
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text
1916
-  (2.1ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
1917
- BEGIN
1918
- RETURN x + y;
1919
- END;
1920
- $$ LANGUAGE plpgsql;
1921
-  (0.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
1922
- BEGIN
1923
- IF x[0] > x[1] THEN
1924
- RETURN ARRAY[x[1], x[0]];
1925
- ELSE
1926
- RETURN x;
1927
- END IF;
1928
- END;
1929
- $$ LANGUAGE plpgsql;
1930
-  (0.3ms) DROP VIEW chats
1931
- PG::UndefinedTable: ERROR: view "chats" does not exist
1932
- : DROP VIEW chats
1933
-  (0.2ms) DROP VIEW messages
1934
- PG::UndefinedTable: ERROR: view "messages" does not exist
1935
- : DROP VIEW messages
1936
-  (2.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1937
-  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1938
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
1939
- Migrating to CreateTestTables (20160208084226)
1940
-  (0.1ms) BEGIN
1941
-  (4.5ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1942
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
1943
-  (2.3ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1944
-  (0.7ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
1945
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
1946
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
1947
-  (0.6ms) COMMIT
1948
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1949
-  (2.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
1950
- FROM pg_constraint c
1951
- JOIN pg_class t1 ON c.conrelid = t1.oid
1952
- JOIN pg_class t2 ON c.confrelid = t2.oid
1953
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1954
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1955
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1956
- WHERE c.contype = 'f'
1957
- AND t1.relname = 'user_messages'
1958
- AND t3.nspname = ANY (current_schemas(false))
1959
- ORDER BY c.conname
1960
- 
1961
-  (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
1962
- FROM pg_constraint c
1963
- JOIN pg_class t1 ON c.conrelid = t1.oid
1964
- JOIN pg_class t2 ON c.confrelid = t2.oid
1965
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1966
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1967
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
1968
- WHERE c.contype = 'f'
1969
- AND t1.relname = 'users'
1970
- AND t3.nspname = ANY (current_schemas(false))
1971
- ORDER BY c.conname
1972
-
1973
-  (7.7ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
1974
- FROM
1975
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
1976
- u1.name as sender_name, u1.id as sender_id,
1977
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1978
- FROM users u1
1979
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
1980
- INNER JOIN users u2 ON (u2.id = um.to_id)
1981
- UNION
1982
- SELECT u1.name as receiver_name, u1.id as receiver_id,
1983
- u2.name as sender_name, u2.id as sender_id,
1984
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
1985
- FROM users u1
1986
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
1987
- INNER JOIN users u2 ON ( u2.id = um.from_id )
1988
- ORDER BY created_at ASC
1989
- ) AS _
1990
-  (13.6ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS ids,
1991
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
1992
- FROM messages
1993
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text
1994
-  (0.1ms) BEGIN
1995
- User Exists (7.0ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Jack' LIMIT 1
1996
- SQL (6.1ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Jack"], ["created_at", "2016-02-08 11:15:47.858212"], ["updated_at", "2016-02-08 11:15:47.858212"]]
1997
-  (6.1ms) COMMIT
1998
-  (0.1ms) BEGIN
1999
- User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Cindy' LIMIT 1
2000
- SQL (0.2ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Cindy"], ["created_at", "2016-02-08 11:15:47.874899"], ["updated_at", "2016-02-08 11:15:47.874899"]]
2001
-  (0.4ms) COMMIT
2002
-  (0.1ms) BEGIN
2003
- User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Henry' LIMIT 1
2004
- SQL (0.2ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Henry"], ["created_at", "2016-02-08 11:15:47.878467"], ["updated_at", "2016-02-08 11:15:47.878467"]]
2005
-  (0.3ms) COMMIT
2006
-  (0.2ms) BEGIN
2007
- SQL (0.4ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 1], ["to_id", 2], ["content", "Hey, how are you?"], ["created_at", "2016-02-08 11:15:47.897453"], ["updated_at", "2016-02-08 11:15:47.897453"]]
2008
-  (6.2ms) COMMIT
2009
-  (0.1ms) BEGIN
2010
- SQL (0.2ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 2], ["to_id", 1], ["content", "I'm fine, and you?"], ["created_at", "2016-02-08 11:15:47.906239"], ["updated_at", "2016-02-08 11:15:47.906239"]]
2011
-  (10.4ms) COMMIT
2012
-  (0.1ms) BEGIN
2013
- SQL (0.2ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 3], ["to_id", 2], ["content", "Me too, I want to chat with you babe!"], ["created_at", "2016-02-08 11:15:47.919381"], ["updated_at", "2016-02-08 11:15:47.919381"]]
2014
-  (0.7ms) COMMIT
2015
- Chat Load (0.2ms) SELECT "chats".* FROM "chats" WHERE (ids && {3})
2016
- PG::SyntaxError: ERROR: syntax error at or near "{"
2017
- LINE 1: SELECT "chats".* FROM "chats" WHERE (ids && {3})
2018
- ^
2019
- : SELECT "chats".* FROM "chats" WHERE (ids && {3})
2020
-  (1.9ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
2021
- BEGIN
2022
- RETURN x + y;
2023
- END;
2024
- $$ LANGUAGE plpgsql;
2025
-  (0.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
2026
- BEGIN
2027
- IF x[0] > x[1] THEN
2028
- RETURN ARRAY[x[1], x[0]];
2029
- ELSE
2030
- RETURN x;
2031
- END IF;
2032
- END;
2033
- $$ LANGUAGE plpgsql;
2034
-  (0.3ms) DROP VIEW chats
2035
- PG::UndefinedTable: ERROR: view "chats" does not exist
2036
- : DROP VIEW chats
2037
-  (0.3ms) DROP VIEW messages
2038
- PG::UndefinedTable: ERROR: view "messages" does not exist
2039
- : DROP VIEW messages
2040
-  (2.8ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2041
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2042
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2043
- Migrating to CreateTestTables (20160208084226)
2044
-  (0.1ms) BEGIN
2045
-  (5.9ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2046
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
2047
-  (2.3ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2048
-  (0.7ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
2049
-  (1.3ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
2050
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
2051
-  (0.7ms) COMMIT
2052
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2053
-  (2.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
2054
- FROM pg_constraint c
2055
- JOIN pg_class t1 ON c.conrelid = t1.oid
2056
- JOIN pg_class t2 ON c.confrelid = t2.oid
2057
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2058
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2059
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2060
- WHERE c.contype = 'f'
2061
- AND t1.relname = 'user_messages'
2062
- AND t3.nspname = ANY (current_schemas(false))
2063
- ORDER BY c.conname
2064
- 
2065
-  (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
2066
- FROM pg_constraint c
2067
- JOIN pg_class t1 ON c.conrelid = t1.oid
2068
- JOIN pg_class t2 ON c.confrelid = t2.oid
2069
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2070
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2071
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2072
- WHERE c.contype = 'f'
2073
- AND t1.relname = 'users'
2074
- AND t3.nspname = ANY (current_schemas(false))
2075
- ORDER BY c.conname
2076
-
2077
-  (12.2ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
2078
- FROM
2079
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
2080
- u1.name as sender_name, u1.id as sender_id,
2081
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2082
- FROM users u1
2083
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
2084
- INNER JOIN users u2 ON (u2.id = um.to_id)
2085
- UNION
2086
- SELECT u1.name as receiver_name, u1.id as receiver_id,
2087
- u2.name as sender_name, u2.id as sender_id,
2088
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2089
- FROM users u1
2090
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
2091
- INNER JOIN users u2 ON ( u2.id = um.from_id )
2092
- ORDER BY created_at ASC
2093
- ) AS _
2094
-  (7.1ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS ids,
2095
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
2096
- FROM messages
2097
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text
2098
-  (0.1ms) BEGIN
2099
- User Exists (0.8ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Jack' LIMIT 1
2100
- SQL (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Jack"], ["created_at", "2016-02-08 11:15:59.897542"], ["updated_at", "2016-02-08 11:15:59.897542"]]
2101
-  (0.3ms) COMMIT
2102
-  (0.1ms) BEGIN
2103
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Cindy' LIMIT 1
2104
- SQL (0.2ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Cindy"], ["created_at", "2016-02-08 11:15:59.900857"], ["updated_at", "2016-02-08 11:15:59.900857"]]
2105
-  (0.3ms) COMMIT
2106
-  (0.1ms) BEGIN
2107
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Henry' LIMIT 1
2108
- SQL (0.2ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Henry"], ["created_at", "2016-02-08 11:15:59.903151"], ["updated_at", "2016-02-08 11:15:59.903151"]]
2109
-  (0.3ms) COMMIT
2110
-  (0.1ms) BEGIN
2111
- SQL (0.4ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 1], ["to_id", 2], ["content", "Hey, how are you?"], ["created_at", "2016-02-08 11:15:59.921384"], ["updated_at", "2016-02-08 11:15:59.921384"]]
2112
-  (0.3ms) COMMIT
2113
-  (0.1ms) BEGIN
2114
- SQL (0.1ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 2], ["to_id", 1], ["content", "I'm fine, and you?"], ["created_at", "2016-02-08 11:15:59.924565"], ["updated_at", "2016-02-08 11:15:59.924565"]]
2115
-  (0.3ms) COMMIT
2116
-  (0.1ms) BEGIN
2117
- SQL (0.1ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 3], ["to_id", 2], ["content", "Me too, I want to chat with you babe!"], ["created_at", "2016-02-08 11:15:59.926647"], ["updated_at", "2016-02-08 11:15:59.926647"]]
2118
-  (0.2ms) COMMIT
2119
- Chat Load (0.3ms) SELECT "chats".* FROM "chats" WHERE (ids && '{3}')
2120
- PG::UndefinedFunction: ERROR: operator does not exist: text && unknown
2121
- LINE 1: SELECT "chats".* FROM "chats" WHERE (ids && '{3}')
2122
- ^
2123
- HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
2124
- : SELECT "chats".* FROM "chats" WHERE (ids && '{3}')
2125
-  (2.6ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
2126
- BEGIN
2127
- RETURN x + y;
2128
- END;
2129
- $$ LANGUAGE plpgsql;
2130
-  (0.7ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
2131
- BEGIN
2132
- IF x[0] > x[1] THEN
2133
- RETURN ARRAY[x[1], x[0]];
2134
- ELSE
2135
- RETURN x;
2136
- END IF;
2137
- END;
2138
- $$ LANGUAGE plpgsql;
2139
-  (0.3ms) DROP VIEW chats
2140
- PG::UndefinedTable: ERROR: view "chats" does not exist
2141
- : DROP VIEW chats
2142
-  (0.2ms) DROP VIEW messages
2143
- PG::UndefinedTable: ERROR: view "messages" does not exist
2144
- : DROP VIEW messages
2145
-  (2.2ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2146
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2147
- ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
2148
- Migrating to CreateTestTables (20160208084226)
2149
-  (0.1ms) BEGIN
2150
-  (5.2ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2151
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
2152
-  (2.1ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2153
-  (0.7ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
2154
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
2155
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
2156
-  (0.5ms) COMMIT
2157
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
2158
-  (2.0ms) 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
2159
- FROM pg_constraint c
2160
- JOIN pg_class t1 ON c.conrelid = t1.oid
2161
- JOIN pg_class t2 ON c.confrelid = t2.oid
2162
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2163
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2164
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2165
- WHERE c.contype = 'f'
2166
- AND t1.relname = 'user_messages'
2167
- AND t3.nspname = ANY (current_schemas(false))
2168
- ORDER BY c.conname
2169
- 
2170
-  (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
2171
- FROM pg_constraint c
2172
- JOIN pg_class t1 ON c.conrelid = t1.oid
2173
- JOIN pg_class t2 ON c.confrelid = t2.oid
2174
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2175
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2176
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2177
- WHERE c.contype = 'f'
2178
- AND t1.relname = 'users'
2179
- AND t3.nspname = ANY (current_schemas(false))
2180
- ORDER BY c.conname
2181
-
2182
-  (7.7ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
2183
- FROM
2184
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
2185
- u1.name as sender_name, u1.id as sender_id,
2186
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2187
- FROM users u1
2188
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
2189
- INNER JOIN users u2 ON (u2.id = um.to_id)
2190
- UNION
2191
- SELECT u1.name as receiver_name, u1.id as receiver_id,
2192
- u2.name as sender_name, u2.id as sender_id,
2193
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2194
- FROM users u1
2195
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
2196
- INNER JOIN users u2 ON ( u2.id = um.from_id )
2197
- ORDER BY created_at ASC
2198
- ) AS _
2199
-  (9.5ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id])::text AS ids,
2200
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
2201
- FROM messages
2202
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])::text
2203
-  (0.2ms) BEGIN
2204
- User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Jack' LIMIT 1
2205
- SQL (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Jack"], ["created_at", "2016-02-08 11:16:22.333360"], ["updated_at", "2016-02-08 11:16:22.333360"]]
2206
-  (0.7ms) COMMIT
2207
-  (0.1ms) BEGIN
2208
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Cindy' LIMIT 1
2209
- SQL (0.1ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Cindy"], ["created_at", "2016-02-08 11:16:22.337516"], ["updated_at", "2016-02-08 11:16:22.337516"]]
2210
-  (0.2ms) COMMIT
2211
-  (0.0ms) BEGIN
2212
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Henry' LIMIT 1
2213
- SQL (0.1ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Henry"], ["created_at", "2016-02-08 11:16:22.339590"], ["updated_at", "2016-02-08 11:16:22.339590"]]
2214
-  (0.3ms) COMMIT
2215
-  (0.1ms) BEGIN
2216
- SQL (0.4ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 1], ["to_id", 2], ["content", "Hey, how are you?"], ["created_at", "2016-02-08 11:16:22.354237"], ["updated_at", "2016-02-08 11:16:22.354237"]]
2217
-  (0.5ms) COMMIT
2218
-  (0.1ms) BEGIN
2219
- SQL (0.1ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 2], ["to_id", 1], ["content", "I'm fine, and you?"], ["created_at", "2016-02-08 11:16:22.357293"], ["updated_at", "2016-02-08 11:16:22.357293"]]
2220
-  (0.4ms) COMMIT
2221
-  (0.1ms) BEGIN
2222
- SQL (0.1ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 3], ["to_id", 2], ["content", "Me too, I want to chat with you babe!"], ["created_at", "2016-02-08 11:16:22.359512"], ["updated_at", "2016-02-08 11:16:22.359512"]]
2223
-  (0.4ms) COMMIT
2224
- Chat Load (0.5ms) SELECT "chats".* FROM "chats" WHERE ('{3}' && ids)
2225
- PG::UndefinedFunction: ERROR: operator does not exist: unknown && text
2226
- LINE 1: SELECT "chats".* FROM "chats" WHERE ('{3}' && ids)
2227
- ^
2228
- HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
2229
- : SELECT "chats".* FROM "chats" WHERE ('{3}' && ids)
2230
-  (1.9ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
2231
- BEGIN
2232
- RETURN x + y;
2233
- END;
2234
- $$ LANGUAGE plpgsql;
2235
-  (0.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
2236
- BEGIN
2237
- IF x[0] > x[1] THEN
2238
- RETURN ARRAY[x[1], x[0]];
2239
- ELSE
2240
- RETURN x;
2241
- END IF;
2242
- END;
2243
- $$ LANGUAGE plpgsql;
2244
-  (0.3ms) DROP VIEW chats
2245
- PG::UndefinedTable: ERROR: view "chats" does not exist
2246
- : DROP VIEW chats
2247
-  (0.2ms) DROP VIEW messages
2248
- PG::UndefinedTable: ERROR: view "messages" does not exist
2249
- : DROP VIEW messages
2250
-  (2.6ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2251
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2252
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
2253
- Migrating to CreateTestTables (20160208084226)
2254
-  (0.1ms) BEGIN
2255
-  (3.0ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2256
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
2257
-  (2.3ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2258
-  (0.7ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
2259
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
2260
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
2261
-  (0.6ms) COMMIT
2262
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2263
-  (1.9ms) 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
2264
- FROM pg_constraint c
2265
- JOIN pg_class t1 ON c.conrelid = t1.oid
2266
- JOIN pg_class t2 ON c.confrelid = t2.oid
2267
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2268
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2269
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2270
- WHERE c.contype = 'f'
2271
- AND t1.relname = 'user_messages'
2272
- AND t3.nspname = ANY (current_schemas(false))
2273
- ORDER BY c.conname
2274
- 
2275
-  (2.0ms) 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
2276
- FROM pg_constraint c
2277
- JOIN pg_class t1 ON c.conrelid = t1.oid
2278
- JOIN pg_class t2 ON c.confrelid = t2.oid
2279
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2280
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2281
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2282
- WHERE c.contype = 'f'
2283
- AND t1.relname = 'users'
2284
- AND t3.nspname = ANY (current_schemas(false))
2285
- ORDER BY c.conname
2286
-
2287
-  (7.7ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
2288
- FROM
2289
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
2290
- u1.name as sender_name, u1.id as sender_id,
2291
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2292
- FROM users u1
2293
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
2294
- INNER JOIN users u2 ON (u2.id = um.to_id)
2295
- UNION
2296
- SELECT u1.name as receiver_name, u1.id as receiver_id,
2297
- u2.name as sender_name, u2.id as sender_id,
2298
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2299
- FROM users u1
2300
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
2301
- INNER JOIN users u2 ON ( u2.id = um.from_id )
2302
- ORDER BY created_at ASC
2303
- ) AS _
2304
-  (14.5ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id]) AS ids,
2305
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
2306
- FROM messages
2307
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])
2308
-  (0.1ms) BEGIN
2309
- User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Jack' LIMIT 1
2310
- SQL (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Jack"], ["created_at", "2016-02-08 11:16:41.288012"], ["updated_at", "2016-02-08 11:16:41.288012"]]
2311
-  (0.3ms) COMMIT
2312
-  (0.1ms) BEGIN
2313
- User Exists (1.3ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Cindy' LIMIT 1
2314
- SQL (0.2ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Cindy"], ["created_at", "2016-02-08 11:16:41.295126"], ["updated_at", "2016-02-08 11:16:41.295126"]]
2315
-  (0.4ms) COMMIT
2316
-  (0.1ms) BEGIN
2317
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Henry' LIMIT 1
2318
- SQL (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Henry"], ["created_at", "2016-02-08 11:16:41.297826"], ["updated_at", "2016-02-08 11:16:41.297826"]]
2319
-  (0.4ms) COMMIT
2320
-  (0.1ms) BEGIN
2321
- SQL (0.3ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 1], ["to_id", 2], ["content", "Hey, how are you?"], ["created_at", "2016-02-08 11:16:41.314137"], ["updated_at", "2016-02-08 11:16:41.314137"]]
2322
-  (0.3ms) COMMIT
2323
-  (0.1ms) BEGIN
2324
- SQL (0.1ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 2], ["to_id", 1], ["content", "I'm fine, and you?"], ["created_at", "2016-02-08 11:16:41.316341"], ["updated_at", "2016-02-08 11:16:41.316341"]]
2325
-  (0.3ms) COMMIT
2326
-  (0.1ms) BEGIN
2327
- SQL (0.2ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 3], ["to_id", 2], ["content", "Me too, I want to chat with you babe!"], ["created_at", "2016-02-08 11:16:41.318849"], ["updated_at", "2016-02-08 11:16:41.318849"]]
2328
-  (0.2ms) COMMIT
2329
- Chat Load (2.2ms) SELECT "chats".* FROM "chats" WHERE ('{3}' && ids)
2330
-  (2.0ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
2331
- BEGIN
2332
- RETURN x + y;
2333
- END;
2334
- $$ LANGUAGE plpgsql;
2335
-  (0.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
2336
- BEGIN
2337
- IF x[0] > x[1] THEN
2338
- RETURN ARRAY[x[1], x[0]];
2339
- ELSE
2340
- RETURN x;
2341
- END IF;
2342
- END;
2343
- $$ LANGUAGE plpgsql;
2344
-  (0.3ms) DROP VIEW chats
2345
- PG::UndefinedTable: ERROR: view "chats" does not exist
2346
- : DROP VIEW chats
2347
-  (0.3ms) DROP VIEW messages
2348
- PG::UndefinedTable: ERROR: view "messages" does not exist
2349
- : DROP VIEW messages
2350
-  (2.4ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2351
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2352
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2353
- Migrating to CreateTestTables (20160208084226)
2354
-  (0.1ms) BEGIN
2355
-  (4.5ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2356
-  (0.6ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
2357
-  (2.1ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2358
-  (0.6ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
2359
-  (0.9ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
2360
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
2361
-  (0.6ms) COMMIT
2362
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2363
-  (2.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
2364
- FROM pg_constraint c
2365
- JOIN pg_class t1 ON c.conrelid = t1.oid
2366
- JOIN pg_class t2 ON c.confrelid = t2.oid
2367
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2368
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2369
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2370
- WHERE c.contype = 'f'
2371
- AND t1.relname = 'user_messages'
2372
- AND t3.nspname = ANY (current_schemas(false))
2373
- ORDER BY c.conname
2374
- 
2375
-  (1.7ms) 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
2376
- FROM pg_constraint c
2377
- JOIN pg_class t1 ON c.conrelid = t1.oid
2378
- JOIN pg_class t2 ON c.confrelid = t2.oid
2379
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2380
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2381
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2382
- WHERE c.contype = 'f'
2383
- AND t1.relname = 'users'
2384
- AND t3.nspname = ANY (current_schemas(false))
2385
- ORDER BY c.conname
2386
-
2387
-  (8.9ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
2388
- FROM
2389
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
2390
- u1.name as sender_name, u1.id as sender_id,
2391
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2392
- FROM users u1
2393
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
2394
- INNER JOIN users u2 ON (u2.id = um.to_id)
2395
- UNION
2396
- SELECT u1.name as receiver_name, u1.id as receiver_id,
2397
- u2.name as sender_name, u2.id as sender_id,
2398
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2399
- FROM users u1
2400
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
2401
- INNER JOIN users u2 ON ( u2.id = um.from_id )
2402
- ORDER BY created_at ASC
2403
- ) AS _
2404
-  (7.5ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id]) AS ids,
2405
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
2406
- FROM messages
2407
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])
2408
-  (0.1ms) BEGIN
2409
- User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Jack' LIMIT 1
2410
- SQL (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Jack"], ["created_at", "2016-02-08 11:17:00.677471"], ["updated_at", "2016-02-08 11:17:00.677471"]]
2411
-  (0.4ms) COMMIT
2412
-  (0.1ms) BEGIN
2413
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Cindy' LIMIT 1
2414
- SQL (0.2ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Cindy"], ["created_at", "2016-02-08 11:17:00.681035"], ["updated_at", "2016-02-08 11:17:00.681035"]]
2415
-  (0.3ms) COMMIT
2416
-  (0.1ms) BEGIN
2417
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Henry' LIMIT 1
2418
- SQL (0.2ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Henry"], ["created_at", "2016-02-08 11:17:00.683817"], ["updated_at", "2016-02-08 11:17:00.683817"]]
2419
-  (0.3ms) COMMIT
2420
-  (0.1ms) BEGIN
2421
- SQL (0.4ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 1], ["to_id", 2], ["content", "Hey, how are you?"], ["created_at", "2016-02-08 11:17:00.705119"], ["updated_at", "2016-02-08 11:17:00.705119"]]
2422
-  (0.3ms) COMMIT
2423
-  (0.1ms) BEGIN
2424
- SQL (0.2ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 2], ["to_id", 1], ["content", "I'm fine, and you?"], ["created_at", "2016-02-08 11:17:00.707797"], ["updated_at", "2016-02-08 11:17:00.707797"]]
2425
-  (0.3ms) COMMIT
2426
-  (0.1ms) BEGIN
2427
- SQL (0.2ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 3], ["to_id", 2], ["content", "Me too, I want to chat with you babe!"], ["created_at", "2016-02-08 11:17:00.710075"], ["updated_at", "2016-02-08 11:17:00.710075"]]
2428
-  (0.3ms) COMMIT
2429
- Chat Load (1.3ms) SELECT "chats".* FROM "chats" WHERE ('{3}' && ids)
2430
- Chat Load (0.8ms) SELECT "chats".* FROM "chats" WHERE ('{2}' && ids)
2431
-  (2.1ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
2432
- BEGIN
2433
- RETURN x + y;
2434
- END;
2435
- $$ LANGUAGE plpgsql;
2436
-  (0.6ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
2437
- BEGIN
2438
- IF x[0] > x[1] THEN
2439
- RETURN ARRAY[x[1], x[0]];
2440
- ELSE
2441
- RETURN x;
2442
- END IF;
2443
- END;
2444
- $$ LANGUAGE plpgsql;
2445
-  (0.4ms) DROP VIEW chats
2446
- PG::UndefinedTable: ERROR: view "chats" does not exist
2447
- : DROP VIEW chats
2448
-  (0.2ms) DROP VIEW messages
2449
- PG::UndefinedTable: ERROR: view "messages" does not exist
2450
- : DROP VIEW messages
2451
-  (2.4ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2452
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2453
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2454
- Migrating to CreateTestTables (20160208084226)
2455
-  (0.1ms) BEGIN
2456
-  (3.0ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2457
-  (6.4ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
2458
-  (13.5ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2459
-  (5.0ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
2460
-  (0.8ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
2461
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
2462
-  (0.7ms) COMMIT
2463
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2464
-  (1.8ms) 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
2465
- FROM pg_constraint c
2466
- JOIN pg_class t1 ON c.conrelid = t1.oid
2467
- JOIN pg_class t2 ON c.confrelid = t2.oid
2468
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2469
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2470
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2471
- WHERE c.contype = 'f'
2472
- AND t1.relname = 'user_messages'
2473
- AND t3.nspname = ANY (current_schemas(false))
2474
- ORDER BY c.conname
2475
- 
2476
-  (2.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
2477
- FROM pg_constraint c
2478
- JOIN pg_class t1 ON c.conrelid = t1.oid
2479
- JOIN pg_class t2 ON c.confrelid = t2.oid
2480
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2481
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2482
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2483
- WHERE c.contype = 'f'
2484
- AND t1.relname = 'users'
2485
- AND t3.nspname = ANY (current_schemas(false))
2486
- ORDER BY c.conname
2487
-
2488
-  (7.2ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
2489
- FROM
2490
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
2491
- u1.name as sender_name, u1.id as sender_id,
2492
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2493
- FROM users u1
2494
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
2495
- INNER JOIN users u2 ON (u2.id = um.to_id)
2496
- UNION
2497
- SELECT u1.name as receiver_name, u1.id as receiver_id,
2498
- u2.name as sender_name, u2.id as sender_id,
2499
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2500
- FROM users u1
2501
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
2502
- INNER JOIN users u2 ON ( u2.id = um.from_id )
2503
- ORDER BY created_at ASC
2504
- ) AS _
2505
-  (6.9ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id]) AS ids,
2506
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
2507
- FROM messages
2508
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])
2509
-  (0.1ms) BEGIN
2510
- User Exists (0.7ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Jack' LIMIT 1
2511
- SQL (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Jack"], ["created_at", "2016-02-08 11:17:36.052301"], ["updated_at", "2016-02-08 11:17:36.052301"]]
2512
-  (0.3ms) COMMIT
2513
-  (0.1ms) BEGIN
2514
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Cindy' LIMIT 1
2515
- SQL (0.1ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Cindy"], ["created_at", "2016-02-08 11:17:36.056048"], ["updated_at", "2016-02-08 11:17:36.056048"]]
2516
-  (0.3ms) COMMIT
2517
-  (0.1ms) BEGIN
2518
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Henry' LIMIT 1
2519
- SQL (0.1ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Henry"], ["created_at", "2016-02-08 11:17:36.058062"], ["updated_at", "2016-02-08 11:17:36.058062"]]
2520
-  (0.2ms) COMMIT
2521
-  (0.1ms) BEGIN
2522
- SQL (0.5ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 1], ["to_id", 2], ["content", "Hey, how are you?"], ["created_at", "2016-02-08 11:17:36.074100"], ["updated_at", "2016-02-08 11:17:36.074100"]]
2523
-  (0.3ms) COMMIT
2524
-  (0.1ms) BEGIN
2525
- SQL (0.2ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 2], ["to_id", 1], ["content", "I'm fine, and you?"], ["created_at", "2016-02-08 11:17:36.077311"], ["updated_at", "2016-02-08 11:17:36.077311"]]
2526
-  (0.3ms) COMMIT
2527
-  (0.1ms) BEGIN
2528
- SQL (0.1ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 3], ["to_id", 2], ["content", "Me too, I want to chat with you babe!"], ["created_at", "2016-02-08 11:17:36.079340"], ["updated_at", "2016-02-08 11:17:36.079340"]]
2529
-  (0.2ms) COMMIT
2530
- Chat Load (2.3ms) SELECT "chats".* FROM "chats" WHERE ('{3}' && ids)
2531
- Chat Load (0.6ms) SELECT "chats".* FROM "chats" WHERE ('{2}' && ids)
2532
- Chat Load (0.6ms) SELECT "chats".* FROM "chats" WHERE ('{1}' && ids)
2533
-  (24.5ms) CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
2534
- BEGIN
2535
- RETURN x + y;
2536
- END;
2537
- $$ LANGUAGE plpgsql;
2538
-  (6.8ms) CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
2539
- BEGIN
2540
- -- Note to myself: selection in array start at 1, not at zero !
2541
- IF x[1]::int > x[2]::int THEN
2542
- RETURN ARRAY[x[2], x[1]];
2543
- ELSE
2544
- RETURN x;
2545
- END IF;
2546
- END;
2547
- $$ LANGUAGE plpgsql;
2548
-  (1.8ms) DROP VIEW chats
2549
- PG::UndefinedTable: ERROR: view "chats" does not exist
2550
- : DROP VIEW chats
2551
-  (0.6ms) DROP VIEW messages
2552
- PG::UndefinedTable: ERROR: view "messages" does not exist
2553
- : DROP VIEW messages
2554
-  (13.9ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2555
-  (10.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2556
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
2557
- Migrating to CreateTestTables (20160208084226)
2558
-  (0.1ms) BEGIN
2559
-  (14.7ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2560
-  (32.5ms) CREATE INDEX "index_users_on_name" ON "users" ("name")
2561
-  (2.7ms) CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
2562
-  (0.7ms) CREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")
2563
-  (0.7ms) CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
2564
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160208084226"]]
2565
-  (12.3ms) COMMIT
2566
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2567
-  (3.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
2568
- FROM pg_constraint c
2569
- JOIN pg_class t1 ON c.conrelid = t1.oid
2570
- JOIN pg_class t2 ON c.confrelid = t2.oid
2571
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2572
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2573
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2574
- WHERE c.contype = 'f'
2575
- AND t1.relname = 'user_messages'
2576
- AND t3.nspname = ANY (current_schemas(false))
2577
- ORDER BY c.conname
2578
- 
2579
-  (2.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
2580
- FROM pg_constraint c
2581
- JOIN pg_class t1 ON c.conrelid = t1.oid
2582
- JOIN pg_class t2 ON c.confrelid = t2.oid
2583
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
2584
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
2585
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
2586
- WHERE c.contype = 'f'
2587
- AND t1.relname = 'users'
2588
- AND t3.nspname = ANY (current_schemas(false))
2589
- ORDER BY c.conname
2590
-
2591
-  (7.5ms) CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
2592
- FROM
2593
- (SELECT u2.name as receiver_name, u2.id as receiver_id,
2594
- u1.name as sender_name, u1.id as sender_id,
2595
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2596
- FROM users u1
2597
- INNER JOIN user_messages um ON ( u1.id = um.from_id )
2598
- INNER JOIN users u2 ON (u2.id = um.to_id)
2599
- UNION
2600
- SELECT u1.name as receiver_name, u1.id as receiver_id,
2601
- u2.name as sender_name, u2.id as sender_id,
2602
- um.content as content, um.updated_at as updated_at, um.created_at as created_at
2603
- FROM users u1
2604
- INNER JOIN user_messages um ON ( u1.id = um.to_id )
2605
- INNER JOIN users u2 ON ( u2.id = um.from_id )
2606
- ORDER BY created_at ASC
2607
- ) AS _
2608
-  (8.2ms) CREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id]) AS ids,
2609
- MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
2610
- FROM messages
2611
- GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])
2612
-  (0.1ms) BEGIN
2613
- User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Jack' LIMIT 1
2614
- SQL (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Jack"], ["created_at", "2016-02-08 11:23:04.696172"], ["updated_at", "2016-02-08 11:23:04.696172"]]
2615
-  (6.1ms) COMMIT
2616
-  (0.1ms) BEGIN
2617
- User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Cindy' LIMIT 1
2618
- SQL (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Cindy"], ["created_at", "2016-02-08 11:23:04.705868"], ["updated_at", "2016-02-08 11:23:04.705868"]]
2619
-  (6.2ms) COMMIT
2620
-  (0.1ms) BEGIN
2621
- User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."name" = 'Henry' LIMIT 1
2622
- SQL (0.2ms) INSERT INTO "users" ("name", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["name", "Henry"], ["created_at", "2016-02-08 11:23:04.715957"], ["updated_at", "2016-02-08 11:23:04.715957"]]
2623
-  (4.9ms) COMMIT
2624
-  (0.1ms) BEGIN
2625
- SQL (0.5ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 1], ["to_id", 2], ["content", "Hey, how are you?"], ["created_at", "2016-02-08 11:23:04.740357"], ["updated_at", "2016-02-08 11:23:04.740357"]]
2626
-  (5.5ms) COMMIT
2627
-  (0.1ms) BEGIN
2628
- SQL (0.2ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 2], ["to_id", 1], ["content", "I'm fine, and you?"], ["created_at", "2016-02-08 11:23:04.748830"], ["updated_at", "2016-02-08 11:23:04.748830"]]
2629
-  (11.1ms) COMMIT
2630
-  (0.1ms) BEGIN
2631
- SQL (0.2ms) INSERT INTO "user_messages" ("from_id", "to_id", "content", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["from_id", 3], ["to_id", 2], ["content", "Me too, I want to chat with you babe!"], ["created_at", "2016-02-08 11:23:04.762637"], ["updated_at", "2016-02-08 11:23:04.762637"]]
2632
-  (0.5ms) COMMIT
2633
- Chat Load (1.7ms) SELECT "chats".* FROM "chats" WHERE ('{3}' && ids)
2634
- Chat Load (0.7ms) SELECT "chats".* FROM "chats" WHERE ('{2}' && ids)
2635
- Chat Load (0.7ms) SELECT "chats".* FROM "chats" WHERE ('{1}' && ids)