each_batched 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -12,6 +12,7 @@ So this library attempts to address these, by providing two additional algorithm
12
12
 
13
13
  * Ruby 1.9.2 - does not support Ruby 1.8!
14
14
  * Rails 3.x - does not support Rails 2!
15
+ * valium gem
15
16
 
16
17
  == Features
17
18
 
data/lib/each_batched.rb CHANGED
@@ -1,4 +1,7 @@
1
- #
1
+
2
+ require 'valium'
3
+
4
+ #
2
5
  # More grouping/batching logic options than what's included in Rails.
3
6
  #
4
7
 
@@ -47,7 +50,9 @@ module EachBatched
47
50
  # * The yielded scope can be lazily loaded (though the id selection query has already run obviously)
48
51
  def batches_by_ids(batch_size=DEFAULT_BATCH_SIZE)
49
52
  reduced_scope = scoped.tap { |s| s.where_values = [] }.offset(nil).limit(nil)
50
- select("#{table_name}.#{primary_key}").collect(&(primary_key.to_sym)).in_groups_of(batch_size, false) do |group_ids|
53
+ # valium's value_of is way faster than select...collect...
54
+ #select("#{table_name}.#{primary_key}").collect(&(primary_key.to_sym)).in_groups_of(batch_size, false) do |group_ids|
55
+ scoped.value_of(primary_key).in_groups_of(batch_size, false) do |group_ids|
51
56
  # keeps select/group/joins/includes, inside inner batched scope
52
57
  yield reduced_scope.where(primary_key => group_ids)
53
58
  end
@@ -1,3 +1,3 @@
1
1
  module EachBatched
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
Binary file
Binary file
@@ -1,408 +1,48 @@
1
-  (1.5ms) select sqlite_version(*)
2
-  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
3
-  (0.0ms) PRAGMA index_list("schema_migrations")
4
-  (1.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
5
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
6
- Migrating to InitializeModels (1)
7
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
8
- Migrating to InitializeModels (1)
9
-  (0.0ms) select sqlite_version(*)
10
-  (0.6ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL) 
11
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer)
12
-  (0.2ms) CREATE TABLE "pruducts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer) 
13
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "product_id" integer, "customer_id" integer)
14
-  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
15
-  (0.4ms) select sqlite_version(*)
16
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
17
-  (0.0ms) PRAGMA index_list("companies")
18
-  (0.0ms) PRAGMA index_list("customers")
19
-  (0.0ms) PRAGMA index_list("pruducts")
20
-  (0.0ms) PRAGMA index_list("purchases")
21
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
22
-  (0.3ms) select sqlite_version(*)
23
-  (1.4ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL) 
24
-  (1.1ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer)
25
-  (1.2ms) CREATE TABLE "pruducts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer) 
26
-  (1.1ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "product_id" integer, "customer_id" integer)
27
-  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
28
-  (0.0ms) PRAGMA index_list("schema_migrations")
29
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
30
-  (0.1ms) SELECT version FROM "schema_migrations"
31
-  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('1')
32
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
33
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
34
- Migrating to InitializeModels (1)
35
-  (0.0ms) select sqlite_version(*)
36
-  (0.6ms) DROP TABLE "purchases"
37
-  (0.2ms) DROP TABLE "products"
38
- SQLite3::SQLException: no such table: products: DROP TABLE "products"
39
-  (0.1ms) select sqlite_version(*)
40
-  (2.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
41
-  (0.0ms) PRAGMA index_list("schema_migrations")
42
-  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
43
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
44
- Migrating to InitializeModels (1)
45
-  (0.6ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL)
46
-  (0.1ms) select sqlite_version(*)
47
-  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
48
-  (0.0ms) PRAGMA index_list("schema_migrations")
49
-  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
50
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
51
- Migrating to InitializeModels (1)
52
-  (0.5ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL)
53
-  (0.1ms) select sqlite_version(*)
54
-  (2.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
55
-  (0.1ms) PRAGMA index_list("schema_migrations")
56
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
57
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
58
- Migrating to InitializeModels (1)
59
-  (0.5ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL)
60
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer) 
61
-  (0.2ms) CREATE TABLE "pruducts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer)
62
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "product_id" integer, "customer_id" integer) 
63
-  (0.1ms) select sqlite_version(*)
64
-  (2.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
65
-  (0.0ms) PRAGMA index_list("schema_migrations")
66
-  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
67
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
68
- Migrating to InitializeModels (1)
69
-  (0.5ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL)
70
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer) 
71
-  (0.2ms) CREATE TABLE "pruducts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer)
72
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "product_id" integer, "customer_id" integer) 
73
-  (0.0ms) PRAGMA index_list("customers")
74
-  (0.1ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
75
-  (0.0ms) PRAGMA index_list("products")
76
-  (0.2ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
77
- SQLite3::SQLException: no such table: main.products: CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
78
-  (0.1ms) select sqlite_version(*)
79
-  (2.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
80
-  (0.0ms) PRAGMA index_list("schema_migrations")
81
-  (1.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
82
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
83
- Migrating to InitializeModels (1)
84
-  (0.5ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL)
85
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer) 
86
-  (0.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer)
87
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "product_id" integer, "customer_id" integer) 
88
-  (0.0ms) PRAGMA index_list("customers")
89
-  (0.1ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
90
-  (0.0ms) PRAGMA index_list("products")
91
-  (0.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
92
-  (0.0ms) PRAGMA index_list("purchases")
93
-  (0.1ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
94
-  (0.0ms) PRAGMA index_list("purchases")
95
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
96
-  (0.1ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
97
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
98
-  (0.5ms) select sqlite_version(*)
99
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
100
-  (0.0ms) PRAGMA index_list("companies")
101
-  (0.1ms) PRAGMA index_list("customers")
102
-  (0.0ms) PRAGMA index_info('index_customers_on_company_id')
103
-  (0.0ms) PRAGMA index_list("products")
104
-  (0.0ms) PRAGMA index_info('index_products_on_company_id')
105
-  (0.0ms) PRAGMA index_list("purchases")
106
-  (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
107
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
108
-  (0.1ms) select sqlite_version(*)
109
-  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
110
-  (0.1ms) PRAGMA index_list("schema_migrations")
111
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
112
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
113
- Migrating to InitializeModels (1)
114
-  (0.7ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL)
115
-  (0.1ms) select sqlite_version(*)
116
-  (2.0ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
117
-  (0.1ms) PRAGMA index_list("schema_migrations")
118
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
119
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
120
- Migrating to InitializeModels (1)
121
-  (0.5ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL)
122
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer) 
123
-  (0.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(100) DEFAULT '' NOT NULL, "company_id" integer)
124
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "product_id" integer, "customer_id" integer) 
125
-  (0.0ms) PRAGMA index_list("customers")
126
-  (0.1ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
127
-  (0.0ms) PRAGMA index_list("products")
128
-  (0.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
129
-  (0.0ms) PRAGMA index_list("purchases")
130
-  (0.1ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
131
-  (0.0ms) PRAGMA index_list("purchases")
132
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
133
-  (0.1ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
134
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
135
-  (0.4ms) select sqlite_version(*)
136
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
137
-  (0.0ms) PRAGMA index_list("companies")
138
-  (0.0ms) PRAGMA index_list("customers")
139
-  (0.0ms) PRAGMA index_info('index_customers_on_company_id')
140
-  (0.0ms) PRAGMA index_list("products")
141
-  (0.0ms) PRAGMA index_info('index_products_on_company_id')
142
-  (0.0ms) PRAGMA index_list("purchases")
143
-  (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
144
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
145
-  (0.1ms) select sqlite_version(*)
146
-  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
147
-  (0.0ms) PRAGMA index_list("schema_migrations")
148
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
149
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
150
- Migrating to InitializeModels (1)
151
-  (0.5ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL)
152
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL, "company_id" integer NOT NULL) 
153
-  (0.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL, "company_id" integer NOT NULL)
154
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL) 
155
-  (0.0ms) PRAGMA index_list("companies")
156
-  (0.1ms) CREATE INDEX "index_companies_on_name" ON "companies" ("name")
157
-  (0.0ms) PRAGMA index_list("customers")
158
-  (0.1ms) CREATE INDEX "index_customers_on_name" ON "customers" ("name")
159
-  (0.0ms) PRAGMA index_list("customers")
160
-  (0.0ms) PRAGMA index_info('index_customers_on_name')
161
-  (0.1ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
162
-  (0.0ms) PRAGMA index_list("products")
163
-  (0.1ms) CREATE INDEX "index_products_on_name" ON "products" ("name")
164
-  (0.0ms) PRAGMA index_list("products")
165
-  (0.0ms) PRAGMA index_info('index_products_on_name')
166
-  (0.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
167
-  (0.0ms) PRAGMA index_list("purchases")
168
-  (0.1ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
169
-  (0.0ms) PRAGMA index_list("purchases")
170
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
171
-  (0.1ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
172
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
173
-  (0.5ms) select sqlite_version(*)
174
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
175
-  (0.0ms) PRAGMA index_list("companies")
176
-  (0.0ms) PRAGMA index_info('index_companies_on_name')
1
+  (5.2ms) select sqlite_version(*)
2
+  (17.9ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL)
3
+  (0.0ms) PRAGMA index_list("companies")
4
+  (6.8ms) CREATE INDEX "index_companies_on_sort" ON "companies" ("sort")
5
+  (7.1ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL) 
177
6
   (0.0ms) PRAGMA index_list("customers")
7
+  (5.6ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
8
+  (0.1ms) PRAGMA index_list("customers")
178
9
   (0.0ms) PRAGMA index_info('index_customers_on_company_id')
179
-  (0.0ms) PRAGMA index_info('index_customers_on_name')
180
-  (0.0ms) PRAGMA index_list("products")
181
-  (0.0ms) PRAGMA index_info('index_products_on_company_id')
182
-  (0.0ms) PRAGMA index_info('index_products_on_name')
183
-  (0.0ms) PRAGMA index_list("purchases")
10
+  (18.4ms) CREATE INDEX "index_customers_on_sort" ON "customers" ("sort")
11
+  (24.9ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL) 
12
+  (0.1ms) PRAGMA index_list("products")
13
+  (16.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
14
+  (0.1ms) PRAGMA index_list("products")
15
+  (0.0ms) PRAGMA index_info('index_products_on_company_id')
16
+  (15.3ms) CREATE INDEX "index_products_on_sort" ON "products" ("sort")
17
+  (10.9ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date DEFAULT '2011-01-01' NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL) 
18
+  (0.1ms) PRAGMA index_list("purchases")
19
+  (6.8ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
20
+  (0.1ms) PRAGMA index_list("purchases")
184
21
   (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
185
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
186
-  (0.1ms) select sqlite_version(*)
187
-  (2.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
188
-  (0.1ms) PRAGMA index_list("schema_migrations")
189
-  (1.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
190
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
191
- Migrating to InitializeModels (1)
192
-  (0.5ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL)
193
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL, "company_id" integer NOT NULL) 
194
-  (0.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL, "company_id" integer NOT NULL)
195
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL) 
196
-  (0.0ms) PRAGMA index_list("companies")
197
-  (0.1ms) CREATE INDEX "index_companies_on_name" ON "companies" ("name")
198
-  (0.0ms) PRAGMA index_list("customers")
199
-  (0.1ms) CREATE INDEX "index_customers_on_name" ON "customers" ("name")
200
-  (0.0ms) PRAGMA index_list("customers")
201
-  (0.0ms) PRAGMA index_info('index_customers_on_name')
202
-  (0.1ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
203
-  (0.0ms) PRAGMA index_list("products")
204
-  (0.1ms) CREATE INDEX "index_products_on_name" ON "products" ("name")
205
-  (0.0ms) PRAGMA index_list("products")
206
-  (0.0ms) PRAGMA index_info('index_products_on_name')
207
-  (0.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
208
-  (0.0ms) PRAGMA index_list("purchases")
209
-  (0.1ms) CREATE INDEX "index_purchases_on_ordered_on" ON "purchases" ("ordered_on")
210
-  (0.0ms) PRAGMA index_list("purchases")
211
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
212
-  (0.1ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
22
+  (6.5ms) CREATE INDEX "index_purchases_on_ordered_on" ON "purchases" ("ordered_on")
213
23
   (0.0ms) PRAGMA index_list("purchases")
214
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
215
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
216
-  (0.1ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
217
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
218
-  (0.4ms) select sqlite_version(*)
219
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
220
-  (0.0ms) PRAGMA index_list("companies")
221
-  (0.0ms) PRAGMA index_info('index_companies_on_name')
222
-  (0.0ms) PRAGMA index_list("customers")
223
-  (0.0ms) PRAGMA index_info('index_customers_on_company_id')
224
-  (0.0ms) PRAGMA index_info('index_customers_on_name')
225
-  (0.0ms) PRAGMA index_list("products")
226
-  (0.0ms) PRAGMA index_info('index_products_on_company_id')
227
-  (0.0ms) PRAGMA index_info('index_products_on_name')
228
-  (0.0ms) PRAGMA index_list("purchases")
24
+  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
229
25
   (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
230
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
231
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
232
-  (0.1ms) select sqlite_version(*)
233
-  (2.0ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
234
-  (0.0ms) PRAGMA index_list("schema_migrations")
235
-  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
236
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
237
- Migrating to InitializeModels (1)
238
-  (0.8ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL)
239
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL) 
240
-  (0.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL)
241
-  (0.3ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date DEFAULT '2011-01-01' NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL) 
242
-  (0.0ms) PRAGMA index_list("companies")
243
-  (0.2ms) CREATE INDEX "index_companies_on_name" ON "companies" ("name")
244
- SQLite3::SQLException: table companies has no column named name: CREATE INDEX "index_companies_on_name" ON "companies" ("name")
245
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
246
-  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
247
- Migrating to InitializeModels (1)
248
-  (0.1ms) select sqlite_version(*)
249
-  (0.7ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL) 
250
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL)
251
-  (0.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL) 
252
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date DEFAULT '2011-01-01' NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL)
253
-  (0.0ms) PRAGMA index_list("companies")
254
-  (0.2ms) CREATE INDEX "index_companies_on_name" ON "companies" ("name")
255
- SQLite3::SQLException: table companies has no column named name: CREATE INDEX "index_companies_on_name" ON "companies" ("name")
256
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
26
+  (6.6ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
27
+  (24.6ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
28
+  (0.1ms) PRAGMA index_list("schema_migrations")
29
+  (20.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
30
+  (0.1ms) SELECT version FROM "schema_migrations"
31
+  (16.8ms) INSERT INTO "schema_migrations" (version) VALUES ('1')
32
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
33
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
257
34
  Migrating to InitializeModels (1)
258
-  (0.0ms) select sqlite_version(*)
259
-  (0.7ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL) 
260
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL)
261
-  (0.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL) 
262
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date DEFAULT '2011-01-01' NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL)
263
-  (0.0ms) PRAGMA index_list("companies")
264
-  (0.1ms) CREATE INDEX "index_companies_on_order" ON "companies" ("order")
265
-  (0.0ms) PRAGMA index_list("customers")
266
-  (0.1ms) CREATE INDEX "index_customers_on_order" ON "customers" ("order")
267
-  (0.0ms) PRAGMA index_list("customers")
268
-  (0.0ms) PRAGMA index_info('index_customers_on_order')
269
-  (0.1ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
270
-  (0.0ms) PRAGMA index_list("products")
271
-  (0.1ms) CREATE INDEX "index_products_on_order" ON "products" ("order")
272
-  (0.0ms) PRAGMA index_list("products")
273
-  (0.0ms) PRAGMA index_info('index_products_on_order')
274
-  (0.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
275
-  (0.0ms) PRAGMA index_list("purchases")
276
-  (0.1ms) CREATE INDEX "index_purchases_on_ordered_on" ON "purchases" ("ordered_on")
277
-  (0.0ms) PRAGMA index_list("purchases")
278
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
279
-  (0.1ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
280
-  (0.0ms) PRAGMA index_list("purchases")
281
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
282
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
283
-  (0.1ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
284
-  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
285
-  (0.5ms) select sqlite_version(*)
286
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
287
-  (0.0ms) PRAGMA index_list("companies")
288
-  (0.0ms) PRAGMA index_info('index_companies_on_order')
289
-  (0.0ms) PRAGMA index_list("customers")
290
-  (0.0ms) PRAGMA index_info('index_customers_on_company_id')
291
-  (0.0ms) PRAGMA index_info('index_customers_on_order')
292
-  (0.0ms) PRAGMA index_list("products")
293
-  (0.0ms) PRAGMA index_info('index_products_on_company_id')
294
-  (0.0ms) PRAGMA index_info('index_products_on_order')
295
-  (0.0ms) PRAGMA index_list("purchases")
296
-  (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
297
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
298
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
299
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
300
35
   (0.4ms) select sqlite_version(*)
301
-  (1.6ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL) 
302
-  (0.0ms) PRAGMA index_list("companies")
303
-  (1.2ms) CREATE INDEX "index_companies_on_order" ON "companies" ("order")
304
-  (1.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL)
305
-  (0.0ms) PRAGMA index_list("customers")
306
-  (1.1ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
307
-  (0.0ms) PRAGMA index_list("customers")
308
-  (0.0ms) PRAGMA index_info('index_customers_on_company_id')
309
-  (1.1ms) CREATE INDEX "index_customers_on_order" ON "customers" ("order")
310
-  (1.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL)
311
-  (0.0ms) PRAGMA index_list("products")
312
-  (1.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
313
-  (0.0ms) PRAGMA index_list("products")
314
-  (0.0ms) PRAGMA index_info('index_products_on_company_id')
315
-  (1.1ms) CREATE INDEX "index_products_on_order" ON "products" ("order")
316
-  (1.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date DEFAULT '2011-01-01' NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL)
317
-  (0.0ms) PRAGMA index_list("purchases")
318
-  (0.9ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
319
-  (0.0ms) PRAGMA index_list("purchases")
320
-  (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
321
-  (0.9ms) CREATE INDEX "index_purchases_on_ordered_on" ON "purchases" ("ordered_on")
322
-  (0.0ms) PRAGMA index_list("purchases")
323
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
324
-  (0.1ms) PRAGMA index_info('index_purchases_on_customer_id')
325
-  (0.9ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
326
-  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
327
-  (0.0ms) PRAGMA index_list("schema_migrations")
328
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
329
-  (0.1ms) SELECT version FROM "schema_migrations"
330
-  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('1')
331
-  (0.1ms) select sqlite_version(*)
332
-  (2.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
333
-  (0.0ms) PRAGMA index_list("schema_migrations")
334
-  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
335
36
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
336
- Migrating to InitializeModels (1)
337
-  (0.6ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL)
338
-  (0.2ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL) 
339
-  (0.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL)
340
-  (0.2ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date DEFAULT '2011-01-01' NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL) 
341
37
   (0.0ms) PRAGMA index_list("companies")
342
-  (0.2ms) CREATE INDEX "index_companies_on_sort" ON "companies" ("sort")
343
-  (0.0ms) PRAGMA index_list("customers")
344
-  (0.1ms) CREATE INDEX "index_customers_on_sort" ON "customers" ("sort")
38
+  (0.1ms) PRAGMA index_info('index_companies_on_sort')
345
39
   (0.0ms) PRAGMA index_list("customers")
346
40
   (0.0ms) PRAGMA index_info('index_customers_on_sort')
347
-  (0.2ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
348
-  (0.0ms) PRAGMA index_list("products")
349
-  (0.1ms) CREATE INDEX "index_products_on_sort" ON "products" ("sort")
41
+  (0.0ms) PRAGMA index_info('index_customers_on_company_id')
350
42
   (0.0ms) PRAGMA index_list("products")
351
43
   (0.0ms) PRAGMA index_info('index_products_on_sort')
352
-  (0.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
353
-  (0.0ms) PRAGMA index_list("purchases")
354
-  (0.1ms) CREATE INDEX "index_purchases_on_ordered_on" ON "purchases" ("ordered_on")
355
-  (0.0ms) PRAGMA index_list("purchases")
356
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
357
-  (0.1ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
358
-  (0.0ms) PRAGMA index_list("purchases")
359
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
360
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
361
-  (0.1ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
362
-  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
363
-  (0.5ms) select sqlite_version(*)
364
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
365
-  (0.0ms) PRAGMA index_list("companies")
366
-  (0.0ms) PRAGMA index_info('index_companies_on_sort')
367
-  (0.0ms) PRAGMA index_list("customers")
368
-  (0.0ms) PRAGMA index_info('index_customers_on_company_id')
369
-  (0.0ms) PRAGMA index_info('index_customers_on_sort')
370
-  (0.0ms) PRAGMA index_list("products")
371
-  (0.0ms) PRAGMA index_info('index_products_on_company_id')
372
-  (0.0ms) PRAGMA index_info('index_products_on_sort')
44
+  (0.0ms) PRAGMA index_info('index_products_on_company_id')
373
45
   (0.0ms) PRAGMA index_list("purchases")
46
+  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
47
+  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
374
48
   (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
375
-  (0.0ms) PRAGMA index_info('index_purchases_on_product_id')
376
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
377
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
378
-  (0.2ms) select sqlite_version(*)
379
-  (2.3ms) CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL) 
380
-  (0.1ms) PRAGMA index_list("companies")
381
-  (1.2ms) CREATE INDEX "index_companies_on_sort" ON "companies" ("sort")
382
-  (1.1ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL)
383
-  (0.0ms) PRAGMA index_list("customers")
384
-  (1.1ms) CREATE INDEX "index_customers_on_company_id" ON "customers" ("company_id")
385
-  (0.0ms) PRAGMA index_list("customers")
386
-  (0.0ms) PRAGMA index_info('index_customers_on_company_id')
387
-  (1.1ms) CREATE INDEX "index_customers_on_sort" ON "customers" ("sort")
388
-  (1.2ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "sort" integer DEFAULT 0 NOT NULL, "company_id" integer NOT NULL)
389
-  (0.0ms) PRAGMA index_list("products")
390
-  (1.1ms) CREATE INDEX "index_products_on_company_id" ON "products" ("company_id")
391
-  (0.0ms) PRAGMA index_list("products")
392
-  (0.0ms) PRAGMA index_info('index_products_on_company_id')
393
-  (1.2ms) CREATE INDEX "index_products_on_sort" ON "products" ("sort")
394
-  (1.1ms) CREATE TABLE "purchases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "ordered_on" date DEFAULT '2011-01-01' NOT NULL, "product_id" integer NOT NULL, "customer_id" integer NOT NULL)
395
-  (0.0ms) PRAGMA index_list("purchases")
396
-  (1.1ms) CREATE INDEX "index_purchases_on_customer_id" ON "purchases" ("customer_id")
397
-  (0.0ms) PRAGMA index_list("purchases")
398
-  (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
399
-  (1.1ms) CREATE INDEX "index_purchases_on_ordered_on" ON "purchases" ("ordered_on")
400
-  (0.0ms) PRAGMA index_list("purchases")
401
-  (0.0ms) PRAGMA index_info('index_purchases_on_ordered_on')
402
-  (0.0ms) PRAGMA index_info('index_purchases_on_customer_id')
403
-  (1.2ms) CREATE INDEX "index_purchases_on_product_id" ON "purchases" ("product_id")
404
-  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
405
-  (0.0ms) PRAGMA index_list("schema_migrations")
406
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
407
-  (0.1ms) SELECT version FROM "schema_migrations"
408
-  (1.2ms) INSERT INTO "schema_migrations" (version) VALUES ('1')