money-rails 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +6 -0
- data/README.md +67 -7
- data/Rakefile +5 -0
- data/lib/money-rails.rb +5 -4
- data/lib/money-rails/active_record/monetizable.rb +20 -5
- data/lib/money-rails/helpers/action_view_extension.rb +36 -0
- data/lib/money-rails/hooks.rb +29 -0
- data/lib/money-rails/railtie.rb +3 -5
- data/lib/money-rails/version.rb +1 -1
- data/money-rails.gemspec +3 -4
- data/spec/active_record/monetizable_spec.rb +32 -1
- data/spec/dummy/app/models/product.rb +4 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20120607210247_add_column_that_allows_nil.rb +5 -0
- data/spec/dummy/db/schema.rb +4 -3
- data/spec/dummy/db/structure.sql +17 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +44 -139
- data/spec/dummy/log/test.log +1714 -15710
- data/spec/helpers/action_view_extension_spec.rb +38 -0
- metadata +85 -129
- data/lib/money-rails/orms.rb +0 -29
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.4.0
|
4
|
+
- Provide ActionView helpers integration.
|
5
|
+
- Map blank value assignments (for monetized fields) to nil.
|
6
|
+
- Allow nil values for monetized fields. (GH-15)
|
7
|
+
- Reworked support for ORM adaptation. (GH-16)
|
8
|
+
|
3
9
|
## 0.3.1
|
4
10
|
|
5
11
|
- Fix bug with string assignment to monetized field. (GH-11)
|
data/README.md
CHANGED
@@ -69,6 +69,22 @@ Now the model objects will have a ```discount``` attribute which
|
|
69
69
|
is a Money object, wrapping the value of ```discount_subunit``` column to a
|
70
70
|
Money instance.
|
71
71
|
|
72
|
+
### Allow nil values
|
73
|
+
|
74
|
+
If you want to allow the assignment of nil and/or blank values to a specific
|
75
|
+
monetized field, you can use the `:allow_nil` parameter like this:
|
76
|
+
|
77
|
+
```
|
78
|
+
# in Product model
|
79
|
+
monetize :optional_price_cents, :allow_nil => true
|
80
|
+
|
81
|
+
# then blank assignments are permitted
|
82
|
+
product.optional_price = nil
|
83
|
+
product.save # returns without errors
|
84
|
+
product.optional_price # => nil
|
85
|
+
product.optional_price_cents # => nil
|
86
|
+
```
|
87
|
+
|
72
88
|
### Currencies
|
73
89
|
|
74
90
|
Money-rails supports a set of options to handle currencies for your
|
@@ -208,18 +224,62 @@ MoneyRails.configure do |config|
|
|
208
224
|
end
|
209
225
|
```
|
210
226
|
|
211
|
-
* default_currecy
|
212
|
-
* include_validations
|
227
|
+
* ```default_currecy```: Set the default (application wide) currency (USD is the default)
|
228
|
+
* ```include_validations```: Permit the inclusion of a ```validates_numericality_of```
|
213
229
|
validation for each monetized field (the default is true)
|
214
|
-
* register_currency
|
230
|
+
* ```register_currency```: Register one custom currency. This option can be
|
215
231
|
used more than once to set more custom currencies. The value should be
|
216
|
-
a hash of all the necessary key/value pairs (important keys:
|
217
|
-
|
218
|
-
|
232
|
+
a hash of all the necessary key/value pairs (important keys: ```:priority```, ```:iso_code```,
|
233
|
+
```:name```, ```:symbol```, ```:symbol_first```, ```:subunit```, ```:subunit_to_unit```,
|
234
|
+
```:thousands_separator```, ```:decimal_mark```).
|
235
|
+
* ```add_rate```: Provide custom exchange rate for currencies in one direction
|
219
236
|
only! This rate is added to the attached bank object.
|
220
|
-
* default_bank
|
237
|
+
* ```default_bank```: The default bank object holding exchange rates etc.
|
221
238
|
(https://github.com/RubyMoney/money#currency-exchange)
|
222
239
|
|
240
|
+
### Helpers
|
241
|
+
|
242
|
+
* the `currency_symbol` helper method
|
243
|
+
|
244
|
+
```
|
245
|
+
<%= currency_symbol %>
|
246
|
+
```
|
247
|
+
This will render a `span` dom element with the default currency symbol.
|
248
|
+
|
249
|
+
* the `humanized_money` helper method
|
250
|
+
|
251
|
+
```
|
252
|
+
<%= humanized_money @money_object %>
|
253
|
+
```
|
254
|
+
This will render a formatted money value without the currency symbol and
|
255
|
+
without the cents part if it contains only zeros (uses
|
256
|
+
`:no_cents_fi_whole flag`).
|
257
|
+
|
258
|
+
* humanize with symbol helper
|
259
|
+
|
260
|
+
```
|
261
|
+
<%= humanized_money_with_symbol @money_object %>
|
262
|
+
```
|
263
|
+
This will render a formatted money value including the currency symbol and
|
264
|
+
without the cents part if it contains only zeros.
|
265
|
+
|
266
|
+
* get the money value without the cents part
|
267
|
+
|
268
|
+
```
|
269
|
+
<%= money_without_cents @money_object %>
|
270
|
+
```
|
271
|
+
This will render a formatted money value without the currency symbol and
|
272
|
+
without the cents part.
|
273
|
+
|
274
|
+
* get the money value without the cents part and including the currency
|
275
|
+
symbol
|
276
|
+
|
277
|
+
```
|
278
|
+
<%= money_without_cents_and_with_symbol @money_object %>
|
279
|
+
```
|
280
|
+
This will render a formatted money value including the currency symbol and
|
281
|
+
without the cents part.
|
282
|
+
|
223
283
|
## Maintainers
|
224
284
|
|
225
285
|
* Andreas Loupasakis (https://github.com/alup)
|
data/Rakefile
CHANGED
data/lib/money-rails.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require "money"
|
2
2
|
require "money-rails/configuration"
|
3
|
+
require "money-rails/version"
|
4
|
+
require 'money-rails/hooks'
|
3
5
|
|
4
6
|
module MoneyRails
|
5
7
|
extend Configuration
|
6
|
-
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
require "money-rails/
|
11
|
-
|
10
|
+
if defined? Rails
|
11
|
+
require "money-rails/railtie"
|
12
|
+
end
|
@@ -55,7 +55,7 @@ module MoneyRails
|
|
55
55
|
|
56
56
|
mappings = [[subunit_name, "cents"], [model_currency_name, "currency_as_string"]]
|
57
57
|
constructor = Proc.new { |cents, currency|
|
58
|
-
Money.new(cents
|
58
|
+
Money.new(cents, currency || self.respond_to?(:currency) &&
|
59
59
|
self.currency || Money.default_currency)
|
60
60
|
}
|
61
61
|
converter = Proc.new { |value|
|
@@ -64,11 +64,13 @@ module MoneyRails
|
|
64
64
|
else
|
65
65
|
mappings = [[subunit_name, "cents"]]
|
66
66
|
constructor = Proc.new { |cents|
|
67
|
-
Money.new(cents
|
67
|
+
Money.new(cents, field_currency_name || self.respond_to?(:currency) &&
|
68
68
|
self.currency || Money.default_currency)
|
69
69
|
}
|
70
70
|
converter = Proc.new { |value|
|
71
|
-
if value.
|
71
|
+
if options[:allow_nil] && value.blank?
|
72
|
+
nil
|
73
|
+
elsif value.respond_to?(:to_money)
|
72
74
|
value.to_money(field_currency_name || self.respond_to?(:currency) &&
|
73
75
|
self.currency || Money.default_currency)
|
74
76
|
else
|
@@ -82,13 +84,26 @@ module MoneyRails
|
|
82
84
|
:class_name => "Money",
|
83
85
|
:mapping => mappings,
|
84
86
|
:constructor => constructor,
|
85
|
-
:converter => converter
|
87
|
+
:converter => converter,
|
88
|
+
:allow_nil => options[:allow_nil]
|
89
|
+
end
|
90
|
+
|
91
|
+
if options[:allow_nil]
|
92
|
+
class_eval do
|
93
|
+
# Fixes issue with composed_of that breaks on blank params
|
94
|
+
# TODO: This should be removed when we will only support rails >=4.0
|
95
|
+
define_method "#{name}_with_blank_support=" do |value|
|
96
|
+
value = nil if value.blank?
|
97
|
+
send "#{name}_without_blank_support=", value
|
98
|
+
end
|
99
|
+
alias_method_chain "#{name}=", :blank_support
|
100
|
+
end
|
86
101
|
end
|
87
102
|
|
88
103
|
# Include numericality validation if needed
|
89
104
|
if MoneyRails.include_validations
|
90
105
|
class_eval do
|
91
|
-
validates_numericality_of subunit_name
|
106
|
+
validates_numericality_of subunit_name, :allow_nil => options[:allow_nil]
|
92
107
|
end
|
93
108
|
end
|
94
109
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module MoneyRails
|
2
|
+
module ActionViewExtension
|
3
|
+
|
4
|
+
def currency_symbol
|
5
|
+
content_tag(:span, Money.default_currency.symbol, :class => "currency_symbol")
|
6
|
+
end
|
7
|
+
|
8
|
+
def humanized_money(value, symbol=false)
|
9
|
+
if value.is_a?(Money)
|
10
|
+
value.format(:no_cents_if_whole => true, :symbol => symbol)
|
11
|
+
elsif value.respond_to?(:to_money)
|
12
|
+
value.to_money.format(:no_cents_if_whole => true, :symbol => symbol)
|
13
|
+
else
|
14
|
+
""
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def humanized_money_with_symbol(value)
|
19
|
+
humanized_money(value, true)
|
20
|
+
end
|
21
|
+
|
22
|
+
def money_without_cents(value, symbol=false)
|
23
|
+
if value.is_a?(Money)
|
24
|
+
value.format(:no_cents => true, :symbol => symbol)
|
25
|
+
elsif value.respond_to?(:to_money)
|
26
|
+
value.to_money.format(:no_cents => true, :symbol => symbol)
|
27
|
+
else
|
28
|
+
""
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def money_without_cents_and_with_symbol(value)
|
33
|
+
money_without_cents(value, true)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module MoneyRails
|
2
|
+
class Hooks
|
3
|
+
def self.init
|
4
|
+
# For Active Record
|
5
|
+
ActiveSupport.on_load(:active_record) do
|
6
|
+
require 'money-rails/active_record/monetizable'
|
7
|
+
::ActiveRecord::Base.send :include, MoneyRails::ActiveRecord::Monetizable
|
8
|
+
end
|
9
|
+
|
10
|
+
# For Mongoid
|
11
|
+
begin; require 'mongoid'; rescue LoadError; end
|
12
|
+
if defined? ::Mongoid
|
13
|
+
if ::Mongoid::VERSION =~ /^2(.*)/
|
14
|
+
# Mongoid 2.x stuff here
|
15
|
+
end
|
16
|
+
|
17
|
+
if ::Mongoid::VERSION =~ /^3(.*)/
|
18
|
+
# Mongoid 3.x stuff here
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# For ActionView
|
23
|
+
ActiveSupport.on_load(:action_view) do
|
24
|
+
require 'money-rails/helpers/action_view_extension'
|
25
|
+
::ActionView::Base.send :include, MoneyRails::ActionViewExtension
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/money-rails/railtie.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module MoneyRails
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
MoneyRails::Orms.extend_for :active_record
|
6
|
-
end
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
initializer 'moneyrails.initialize' do
|
4
|
+
MoneyRails::Hooks.init
|
7
5
|
end
|
8
6
|
end
|
9
7
|
end
|
data/lib/money-rails/version.rb
CHANGED
data/money-rails.gemspec
CHANGED
@@ -25,8 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_dependency "railties", "~> 3.0"
|
26
26
|
|
27
27
|
s.add_development_dependency "rails", "~> 3.0"
|
28
|
-
s.add_development_dependency "
|
29
|
-
s.add_development_dependency "rspec",
|
30
|
-
s.add_development_dependency "rspec
|
31
|
-
s.add_development_dependency "guard-rspec", "~> 0.7.2"
|
28
|
+
s.add_development_dependency "rspec", "~> 2.10"
|
29
|
+
s.add_development_dependency "rspec-rails", "~> 2.10"
|
30
|
+
s.add_development_dependency "guard-rspec", "~> 1.1"
|
32
31
|
end
|
@@ -5,7 +5,7 @@ describe MoneyRails::ActiveRecord::Monetizable do
|
|
5
5
|
describe "monetize" do
|
6
6
|
before :each do
|
7
7
|
@product = Product.create(:price_cents => 3000, :discount => 150,
|
8
|
-
:bonus_cents => 200)
|
8
|
+
:bonus_cents => 200, :optional_price => 100)
|
9
9
|
@service = Service.create(:charge_cents => 2000, :discount_cents => 120)
|
10
10
|
end
|
11
11
|
|
@@ -37,6 +37,17 @@ describe MoneyRails::ActiveRecord::Monetizable do
|
|
37
37
|
@product.save.should be_true
|
38
38
|
end
|
39
39
|
|
40
|
+
it "doesn't allow nil by default" do
|
41
|
+
@product.price_cents = nil
|
42
|
+
@product.save.should be_false
|
43
|
+
end
|
44
|
+
|
45
|
+
it "allows nil if optioned" do
|
46
|
+
@product.optional_price = nil
|
47
|
+
@product.save.should be_true
|
48
|
+
@product.optional_price.should be_nil
|
49
|
+
end
|
50
|
+
|
40
51
|
it "uses Money default currency if :with_currency has not been used" do
|
41
52
|
@service.discount.currency.should == Money::Currency.find(:eur)
|
42
53
|
end
|
@@ -133,6 +144,26 @@ describe MoneyRails::ActiveRecord::Monetizable do
|
|
133
144
|
@service.discount.currency_as_string.should == "EUR"
|
134
145
|
end
|
135
146
|
|
147
|
+
it "sets field to nil, in nil assignments if allow_nil is set" do
|
148
|
+
@product.optional_price = nil
|
149
|
+
@product.save.should be_true
|
150
|
+
@product.optional_price.should be_nil
|
151
|
+
end
|
152
|
+
|
153
|
+
it "sets field to nil, in instantiation if allow_nil is set" do
|
154
|
+
pr = Product.new(:optional_price => nil, :price_cents => 5320,
|
155
|
+
:discount => 350, :bonus_cents => 320)
|
156
|
+
pr.optional_price.should be_nil
|
157
|
+
pr.save.should be_true
|
158
|
+
pr.optional_price.should be_nil
|
159
|
+
end
|
160
|
+
|
161
|
+
it "sets field to nil, in blank assignments if allow_nil is set" do
|
162
|
+
@product.optional_price = ""
|
163
|
+
@product.save.should be_true
|
164
|
+
@product.optional_price.should be_nil
|
165
|
+
end
|
166
|
+
|
136
167
|
context "for model with currency column:" do
|
137
168
|
before :each do
|
138
169
|
@transaction = Transaction.create(:amount_cents => 2400, :tax_cents => 600,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Product < ActiveRecord::Base
|
2
2
|
|
3
3
|
attr_accessible :price_cents, :discount, :bonus_cents,
|
4
|
-
:price, :discount_value, :bonus
|
4
|
+
:price, :discount_value, :bonus, :optional_price_cents, :optional_price
|
5
5
|
|
6
6
|
# Use USD as model level currency
|
7
7
|
register_currency :usd
|
@@ -12,6 +12,9 @@ class Product < ActiveRecord::Base
|
|
12
12
|
# Use a custom name for the Money attribute
|
13
13
|
monetize :discount, :as => "discount_value"
|
14
14
|
|
15
|
+
# Allow nil
|
16
|
+
monetize :optional_price_cents, :allow_nil => true
|
17
|
+
|
15
18
|
# Override default currency (EUR) with a specific one (GBP) for this field only
|
16
19
|
monetize :bonus_cents, :with_currency => :gbp
|
17
20
|
|
Binary file
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
14
|
+
ActiveRecord::Schema.define(:version => 20120607210247) do
|
15
15
|
|
16
16
|
create_table "dummy_products", :force => true do |t|
|
17
17
|
t.string "currency"
|
@@ -23,9 +23,10 @@ ActiveRecord::Schema.define(:version => 20120528210103) do
|
|
23
23
|
create_table "products", :force => true do |t|
|
24
24
|
t.integer "price_cents"
|
25
25
|
t.integer "discount"
|
26
|
-
t.datetime "created_at",
|
27
|
-
t.datetime "updated_at",
|
26
|
+
t.datetime "created_at", :null => false
|
27
|
+
t.datetime "updated_at", :null => false
|
28
28
|
t.integer "bonus_cents"
|
29
|
+
t.integer "optional_price_cents"
|
29
30
|
end
|
30
31
|
|
31
32
|
create_table "services", :force => true do |t|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
CREATE TABLE "dummy_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "currency" varchar(255), "price_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL);
|
2
|
+
CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer, "optional_price_cents" integer);
|
3
|
+
CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
|
4
|
+
CREATE TABLE "services" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "charge_cents" integer, "discount_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL);
|
5
|
+
CREATE TABLE "transactions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "amount_cents" integer, "tax_cents" integer, "currency" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL);
|
6
|
+
CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
|
7
|
+
INSERT INTO schema_migrations (version) VALUES ('20120331190108');
|
8
|
+
|
9
|
+
INSERT INTO schema_migrations (version) VALUES ('20120402080348');
|
10
|
+
|
11
|
+
INSERT INTO schema_migrations (version) VALUES ('20120524052716');
|
12
|
+
|
13
|
+
INSERT INTO schema_migrations (version) VALUES ('20120528181002');
|
14
|
+
|
15
|
+
INSERT INTO schema_migrations (version) VALUES ('20120528210103');
|
16
|
+
|
17
|
+
INSERT INTO schema_migrations (version) VALUES ('20120607210247');
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -1,163 +1,68 @@
|
|
1
|
-
[1m[36m (0.
|
2
|
-
[1m[35m (123.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
3
|
-
[1m[36m (0.1ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
4
|
-
[1m[35m (83.6ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
5
|
-
[1m[36m (0.2ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
6
|
-
Migrating to CreateProducts (20120331190108)
|
7
|
-
[1m[35m (0.1ms)[0m begin transaction
|
8
|
-
[1m[36m (1.0ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
9
|
-
[1m[35m (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20120331190108')
|
10
|
-
[1m[36m (176.2ms)[0m [1mcommit transaction[0m
|
11
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
12
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
13
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("products")
|
14
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
15
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
16
|
-
[1m[36m (127.2ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
17
|
-
[1m[35m (113.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
18
|
-
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
19
|
-
[1m[35m (133.4ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
20
|
-
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
21
|
-
[1m[35m (115.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
|
22
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
1
|
+
[1m[36m (0.0ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
23
2
|
Migrating to CreateProducts (20120331190108)
|
24
3
|
Migrating to AddBonusCentsToProduct (20120402080348)
|
25
|
-
|
26
|
-
Migrating to CreateServices (20120524052716)
|
27
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
4
|
+
[1m[35m (0.0ms)[0m select sqlite_version(*)
|
28
5
|
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
29
|
-
[1m[35m (0.
|
30
|
-
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('
|
31
|
-
[1m[35m (
|
32
|
-
|
6
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "products" ADD "bonus_cents" integer
|
7
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120402080348')[0m
|
8
|
+
[1m[35m (90.4ms)[0m commit transaction
|
9
|
+
Migrating to AddCurrencyToProduct (20120402080614)
|
10
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11
|
+
[1m[35m (0.4ms)[0m ALTER TABLE "products" ADD "currency" varchar(255)
|
12
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120402080614')[0m
|
13
|
+
[1m[35m (69.9ms)[0m commit transaction
|
14
|
+
[1m[36m (0.2ms)[0m [1mselect sqlite_version(*)[0m
|
33
15
|
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
34
16
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("products")[0m
|
35
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("services")
|
36
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
37
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
38
|
-
[1m[36m (156.5ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer, "currency" varchar(255)) [0m
|
39
|
-
[1m[35m (95.7ms)[0m CREATE TABLE "services" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "charge_cents" integer, "discount_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
40
|
-
[1m[36m (127.9ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
41
|
-
[1m[35m (0.1ms)[0m PRAGMA index_list("schema_migrations")
|
42
|
-
[1m[36m (103.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
43
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
44
|
-
[1m[36m (87.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120524052716')[0m
|
45
|
-
[1m[35m (88.5ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
|
46
|
-
[1m[36m (110.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120402080614')[0m
|
47
|
-
[1m[35m (99.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
|
48
|
-
[1m[36m (0.3ms)[0m [1mSELECT version FROM schema_migrations[0m
|
49
17
|
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
50
|
-
[1m[35m (0.
|
51
|
-
Migrating to CreateServices (20120524052716)
|
52
|
-
[1m[36m (0.0ms)[0m [1mselect sqlite_version(*)[0m
|
53
|
-
[1m[35m (0.0ms)[0m begin transaction
|
54
|
-
[1m[36m (0.5ms)[0m [1mDROP TABLE "services"[0m
|
55
|
-
[1m[35m (0.1ms)[0m DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120524052716'
|
56
|
-
[1m[36m (113.5ms)[0m [1mcommit transaction[0m
|
57
|
-
[1m[35m (0.7ms)[0m select sqlite_version(*)
|
58
|
-
[1m[36m (0.2ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
59
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("products")
|
60
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
61
|
-
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
18
|
+
[1m[35m (0.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
62
19
|
Migrating to AddCurrencyToProduct (20120402080614)
|
63
20
|
[1m[36m (0.0ms)[0m [1mselect sqlite_version(*)[0m
|
64
21
|
[1m[35m (0.0ms)[0m begin transaction
|
65
|
-
[1m[36m (0.
|
22
|
+
[1m[36m (0.3ms)[0m [1mCREATE TEMPORARY TABLE "altered_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer, "currency" varchar(255)) [0m
|
66
23
|
[1m[35m (0.0ms)[0m PRAGMA index_list("products")
|
67
24
|
[1m[36m (0.1ms)[0m [1mSELECT * FROM "products"[0m
|
68
|
-
[1m[35m (0.
|
69
|
-
[1m[36m (0.
|
25
|
+
[1m[35m (0.1ms)[0m DROP TABLE "products"
|
26
|
+
[1m[36m (0.1ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer) [0m
|
70
27
|
[1m[35m (0.0ms)[0m PRAGMA index_list("altered_products")
|
71
|
-
[1m[36m (0.
|
72
|
-
[1m[35m (0.
|
28
|
+
[1m[36m (0.0ms)[0m [1mSELECT * FROM "altered_products"[0m
|
29
|
+
[1m[35m (0.1ms)[0m DROP TABLE "altered_products"
|
73
30
|
[1m[36m (0.1ms)[0m [1mDELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120402080614'[0m
|
74
|
-
[1m[35m (
|
31
|
+
[1m[35m (147.4ms)[0m commit transaction
|
75
32
|
[1m[36m (0.3ms)[0m [1mselect sqlite_version(*)[0m
|
76
33
|
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
77
34
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("products")[0m
|
78
|
-
[1m[36m (0.1ms)[0m [1mSELECT version FROM schema_migrations[0m
|
79
|
-
[1m[36m (0.1ms)[0m [1mSELECT version FROM schema_migrations[0m
|
80
35
|
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
81
|
-
|
36
|
+
[1m[35m (0.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
82
37
|
Migrating to AddBonusCentsToProduct (20120402080348)
|
83
|
-
|
84
|
-
[1m[35m (0.0ms)[0m
|
85
|
-
[1m[36m (0.
|
86
|
-
[1m[35m (0.
|
87
|
-
[1m[36m (0.
|
88
|
-
[1m[35m (
|
89
|
-
[1m[36m (0.
|
90
|
-
[1m[35m (0.
|
91
|
-
[1m[36m (0.
|
92
|
-
[1m[35m (0.1ms)[0m
|
93
|
-
[1m[36m (0.1ms)[0m [
|
94
|
-
[1m[35m (
|
95
|
-
[1m[36m (
|
96
|
-
[1m[35m (
|
97
|
-
[1m[36m (127.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
98
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("schema_migrations")
|
99
|
-
[1m[36m (82.5ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
100
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
101
|
-
[1m[36m (76.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120524052716')[0m
|
102
|
-
[1m[35m (88.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
|
103
|
-
[1m[36m (77.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120331190108')[0m
|
104
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
105
|
-
Migrating to CreateProducts (20120331190108)
|
106
|
-
Migrating to AddBonusCentsToProduct (20120402080348)
|
107
|
-
Migrating to CreateServices (20120524052716)
|
108
|
-
Migrating to CreateTransactions (20120528181002)
|
109
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
110
|
-
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
111
|
-
[1m[35m (0.6ms)[0m CREATE TABLE "transactions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "amount_cents" integer, "tax_cents" integer, "currency" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
112
|
-
[1m[36m (0.2ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120528181002')[0m
|
113
|
-
[1m[35m (167.5ms)[0m commit transaction
|
114
|
-
[1m[36m (0.4ms)[0m [1mselect sqlite_version(*)[0m
|
115
|
-
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
38
|
+
[1m[36m (0.0ms)[0m [1mselect sqlite_version(*)[0m
|
39
|
+
[1m[35m (0.0ms)[0m begin transaction
|
40
|
+
[1m[36m (0.3ms)[0m [1mCREATE TEMPORARY TABLE "altered_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer) [0m
|
41
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("products")
|
42
|
+
[1m[36m (0.1ms)[0m [1mSELECT * FROM "products"[0m
|
43
|
+
[1m[35m (0.1ms)[0m DROP TABLE "products"
|
44
|
+
[1m[36m (0.1ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
45
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("altered_products")
|
46
|
+
[1m[36m (0.0ms)[0m [1mSELECT * FROM "altered_products"[0m
|
47
|
+
[1m[35m (0.1ms)[0m DROP TABLE "altered_products"
|
48
|
+
[1m[36m (0.1ms)[0m [1mDELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120402080348'[0m
|
49
|
+
[1m[35m (114.1ms)[0m commit transaction
|
50
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
51
|
+
[1m[35m (0.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
116
52
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("products")[0m
|
117
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("services")
|
118
|
-
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("transactions")[0m
|
119
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
120
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
121
|
-
[1m[36m (165.3ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer) [0m
|
122
|
-
[1m[35m (91.6ms)[0m CREATE TABLE "services" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "charge_cents" integer, "discount_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
123
|
-
[1m[36m (119.4ms)[0m [1mCREATE TABLE "transactions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "amount_cents" integer, "tax_cents" integer, "currency" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
124
|
-
[1m[35m (90.7ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
125
|
-
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
126
|
-
[1m[35m (134.6ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
127
|
-
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
128
|
-
[1m[35m (97.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120528181002')
|
129
|
-
[1m[36m (88.6ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120524052716')[0m
|
130
|
-
[1m[35m (88.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
|
131
|
-
[1m[36m (110.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120331190108')[0m
|
132
53
|
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
133
54
|
Migrating to CreateProducts (20120331190108)
|
134
55
|
Migrating to AddBonusCentsToProduct (20120402080348)
|
135
|
-
Migrating to CreateServices (20120524052716)
|
136
|
-
Migrating to CreateTransactions (20120528181002)
|
137
|
-
Migrating to CreateDummyProducts (20120528210103)
|
138
56
|
[1m[35m (0.0ms)[0m select sqlite_version(*)
|
139
57
|
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
140
|
-
[1m[35m (0.
|
141
|
-
[1m[36m (0.
|
142
|
-
[1m[35m (
|
143
|
-
|
144
|
-
[1m[
|
145
|
-
[1m[
|
146
|
-
[1m[
|
147
|
-
[1m[
|
148
|
-
[1m[
|
149
|
-
[1m[
|
150
|
-
[1m[
|
151
|
-
[1m[36m (157.0ms)[0m [1mCREATE TABLE "dummy_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "currency" varchar(255), "price_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
152
|
-
[1m[35m (122.6ms)[0m CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer)
|
153
|
-
[1m[36m (123.4ms)[0m [1mCREATE TABLE "services" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "charge_cents" integer, "discount_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
154
|
-
[1m[35m (95.8ms)[0m CREATE TABLE "transactions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "amount_cents" integer, "tax_cents" integer, "currency" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
155
|
-
[1m[36m (128.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
156
|
-
[1m[35m (0.1ms)[0m PRAGMA index_list("schema_migrations")
|
157
|
-
[1m[36m (102.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
158
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
159
|
-
[1m[36m (109.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120528210103')[0m
|
160
|
-
[1m[35m (110.8ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120524052716')
|
161
|
-
[1m[36m (121.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120402080348')[0m
|
162
|
-
[1m[35m (99.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120528181002')
|
163
|
-
[1m[36m (99.5ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120331190108')[0m
|
58
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "products" ADD "bonus_cents" integer
|
59
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120402080348')[0m
|
60
|
+
[1m[35m (108.4ms)[0m commit transaction
|
61
|
+
Migrating to AddCurrencyToProduct (20120402080614)
|
62
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
63
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "products" ADD "currency" varchar(255)
|
64
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120402080614')[0m
|
65
|
+
[1m[35m (76.9ms)[0m commit transaction
|
66
|
+
[1m[36m (0.4ms)[0m [1mselect sqlite_version(*)[0m
|
67
|
+
[1m[35m (0.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
68
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("products")[0m
|