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.
@@ -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: Set the default (application wide) currency (USD is the default)
212
- * include_validations: Permit the inclusion of a ```validates_numericality_of```
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: Register one custom currency. This option can be
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: :priority, :iso_code, :name,
217
- :symbol, :symbol_first, :subunit, :subunit_to_unit, :thousands_separator, :decimal_mark).
218
- * add_rate: Provide custom exchange rate for currencies in one direction
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: The default bank object holding exchange rates etc.
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
@@ -18,3 +18,8 @@ RSpec::Core::RakeTask.new
18
18
 
19
19
  task :default => :spec
20
20
  task :test => :spec
21
+
22
+ desc "Update AUTHORS file"
23
+ task :authors do
24
+ sh "git shortlog -s | awk '{ print $2 \" \" $3 }' > AUTHORS"
25
+ end
@@ -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
- require "money-rails/version"
10
- require "money-rails/orms"
11
- require "money-rails/railtie"
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 || 0, currency || self.respond_to?(:currency) &&
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 || 0, field_currency_name || self.respond_to?(:currency) &&
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.respond_to?(:to_money)
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
@@ -1,9 +1,7 @@
1
1
  module MoneyRails
2
- module Monetizable
3
- class Railtie < ::Rails::Railtie
4
- initializer "moneyrails.initialize" do
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
@@ -1,3 +1,3 @@
1
1
  module MoneyRails
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -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 "sqlite3", "~> 1.3.6"
29
- s.add_development_dependency "rspec", "~> 2.9.0"
30
- s.add_development_dependency "rspec-rails", "~> 2.9.0"
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
 
@@ -0,0 +1,5 @@
1
+ class AddColumnThatAllowsNil < ActiveRecord::Migration
2
+ def change
3
+ add_column :products, :optional_price_cents, :integer
4
+ end
5
+ end
@@ -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 => 20120528210103) do
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", :null => false
27
- t.datetime "updated_at", :null => false
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');
Binary file
@@ -1,163 +1,68 @@
1
-  (0.1ms) select sqlite_version(*)
2
-  (123.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
3
-  (0.1ms) PRAGMA index_list("schema_migrations")
4
-  (83.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
5
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
6
- Migrating to CreateProducts (20120331190108)
7
-  (0.1ms) begin transaction
8
-  (1.0ms) 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) 
9
-  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120331190108')
10
-  (176.2ms) commit transaction
11
-  (0.3ms) select sqlite_version(*)
12
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
13
-  (0.0ms) PRAGMA index_list("products")
14
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
15
-  (0.3ms) select sqlite_version(*)
16
-  (127.2ms) 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) 
17
-  (113.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
18
-  (0.0ms) PRAGMA index_list("schema_migrations")
19
-  (133.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
20
-  (0.1ms) SELECT version FROM "schema_migrations"
21
-  (115.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
22
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
1
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
23
2
  Migrating to CreateProducts (20120331190108)
24
3
  Migrating to AddBonusCentsToProduct (20120402080348)
25
- Migrating to AddCurrencyToProduct (20120402080614)
26
- Migrating to CreateServices (20120524052716)
27
-  (0.1ms) select sqlite_version(*)
4
+  (0.0ms) select sqlite_version(*)
28
5
   (0.0ms) begin transaction
29
-  (0.6ms) 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)
30
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120524052716')
31
-  (158.1ms) commit transaction
32
-  (0.3ms) select sqlite_version(*)
6
+  (0.2ms) ALTER TABLE "products" ADD "bonus_cents" integer
7
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120402080348')
8
+  (90.4ms) commit transaction
9
+ Migrating to AddCurrencyToProduct (20120402080614)
10
+  (0.1ms) begin transaction
11
+  (0.4ms) ALTER TABLE "products" ADD "currency" varchar(255)
12
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120402080614')
13
+  (69.9ms) commit transaction
14
+  (0.2ms) select sqlite_version(*)
33
15
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
34
16
   (0.0ms) PRAGMA index_list("products")
35
-  (0.0ms) PRAGMA index_list("services")
36
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
37
-  (0.3ms) select sqlite_version(*)
38
-  (156.5ms) 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, "currency" varchar(255)) 
39
-  (95.7ms) 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
-  (127.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
41
-  (0.1ms) PRAGMA index_list("schema_migrations")
42
-  (103.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
43
-  (0.2ms) SELECT version FROM "schema_migrations"
44
-  (87.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20120524052716')
45
-  (88.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
46
-  (110.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20120402080614')
47
-  (99.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
48
-  (0.3ms) SELECT version FROM schema_migrations
49
17
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
50
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
51
- Migrating to CreateServices (20120524052716)
52
-  (0.0ms) select sqlite_version(*)
53
-  (0.0ms) begin transaction
54
-  (0.5ms) DROP TABLE "services"
55
-  (0.1ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120524052716'
56
-  (113.5ms) commit transaction
57
-  (0.7ms) select sqlite_version(*)
58
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
59
-  (0.0ms) PRAGMA index_list("products")
60
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
61
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
18
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
62
19
  Migrating to AddCurrencyToProduct (20120402080614)
63
20
   (0.0ms) select sqlite_version(*)
64
21
   (0.0ms) begin transaction
65
-  (0.6ms) CREATE 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)) 
22
+  (0.3ms) CREATE 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)) 
66
23
   (0.0ms) PRAGMA index_list("products")
67
24
   (0.1ms) SELECT * FROM "products"
68
-  (0.2ms) DROP TABLE "products"
69
-  (0.2ms) 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) 
25
+  (0.1ms) DROP TABLE "products"
26
+  (0.1ms) 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) 
70
27
   (0.0ms) PRAGMA index_list("altered_products")
71
-  (0.1ms) SELECT * FROM "altered_products"
72
-  (0.2ms) DROP TABLE "altered_products"
28
+  (0.0ms) SELECT * FROM "altered_products"
29
+  (0.1ms) DROP TABLE "altered_products"
73
30
   (0.1ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120402080614'
74
-  (127.3ms) commit transaction
31
+  (147.4ms) commit transaction
75
32
   (0.3ms) select sqlite_version(*)
76
33
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
77
34
   (0.0ms) PRAGMA index_list("products")
78
-  (0.1ms) SELECT version FROM schema_migrations
79
-  (0.1ms) SELECT version FROM schema_migrations
80
35
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
81
- Migrating to CreateProducts (20120331190108)
36
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
82
37
  Migrating to AddBonusCentsToProduct (20120402080348)
83
- Migrating to CreateServices (20120524052716)
84
-  (0.0ms) select sqlite_version(*)
85
-  (0.0ms) begin transaction
86
-  (0.6ms) 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)
87
-  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120524052716')
88
-  (194.2ms) commit transaction
89
-  (0.7ms) select sqlite_version(*)
90
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
91
-  (0.1ms) PRAGMA index_list("products")
92
-  (0.1ms) PRAGMA index_list("services")
93
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
94
-  (0.3ms) select sqlite_version(*)
95
-  (144.5ms) 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) 
96
-  (106.8ms) 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)
97
-  (127.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
98
-  (0.0ms) PRAGMA index_list("schema_migrations")
99
-  (82.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
100
-  (0.2ms) SELECT version FROM "schema_migrations"
101
-  (76.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20120524052716')
102
-  (88.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
103
-  (77.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
104
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
105
- Migrating to CreateProducts (20120331190108)
106
- Migrating to AddBonusCentsToProduct (20120402080348)
107
- Migrating to CreateServices (20120524052716)
108
- Migrating to CreateTransactions (20120528181002)
109
-  (0.1ms) select sqlite_version(*)
110
-  (0.0ms) begin transaction
111
-  (0.6ms) 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
-  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120528181002')
113
-  (167.5ms) commit transaction
114
-  (0.4ms) select sqlite_version(*)
115
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
38
+  (0.0ms) select sqlite_version(*)
39
+  (0.0ms) begin transaction
40
+  (0.3ms) CREATE 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) 
41
+  (0.0ms) PRAGMA index_list("products")
42
+  (0.1ms) SELECT * FROM "products"
43
+  (0.1ms) DROP TABLE "products"
44
+  (0.1ms) 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) 
45
+  (0.0ms) PRAGMA index_list("altered_products")
46
+  (0.0ms) SELECT * FROM "altered_products"
47
+  (0.1ms) DROP TABLE "altered_products"
48
+  (0.1ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120402080348'
49
+  (114.1ms) commit transaction
50
+  (0.1ms) select sqlite_version(*)
51
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
116
52
   (0.0ms) PRAGMA index_list("products")
117
-  (0.0ms) PRAGMA index_list("services")
118
-  (0.0ms) PRAGMA index_list("transactions")
119
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
120
-  (0.3ms) select sqlite_version(*)
121
-  (165.3ms) 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) 
122
-  (91.6ms) 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
-  (119.4ms) 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) 
124
-  (90.7ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
125
-  (0.0ms) PRAGMA index_list("schema_migrations")
126
-  (134.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
127
-  (0.1ms) SELECT version FROM "schema_migrations"
128
-  (97.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20120528181002')
129
-  (88.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20120524052716')
130
-  (88.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
131
-  (110.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
132
53
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
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
   (0.0ms) select sqlite_version(*)
139
57
   (0.0ms) begin transaction
140
-  (0.6ms) 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)
141
-  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120528210103')
142
-  (140.3ms) commit transaction
143
-  (0.8ms) select sqlite_version(*)
144
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
145
-  (0.0ms) PRAGMA index_list("dummy_products")
146
-  (0.0ms) PRAGMA index_list("products")
147
-  (0.0ms) PRAGMA index_list("services")
148
-  (0.0ms) PRAGMA index_list("transactions")
149
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
150
-  (0.3ms) select sqlite_version(*)
151
-  (157.0ms) 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) 
152
-  (122.6ms) 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
-  (123.4ms) 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) 
154
-  (95.8ms) 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
-  (128.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
156
-  (0.1ms) PRAGMA index_list("schema_migrations")
157
-  (102.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
158
-  (0.2ms) SELECT version FROM "schema_migrations"
159
-  (109.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20120528210103')
160
-  (110.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20120524052716')
161
-  (121.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
162
-  (99.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20120528181002')
163
-  (99.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
58
+  (0.2ms) ALTER TABLE "products" ADD "bonus_cents" integer
59
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120402080348')
60
+  (108.4ms) commit transaction
61
+ Migrating to AddCurrencyToProduct (20120402080614)
62
+  (0.0ms) begin transaction
63
+  (0.2ms) ALTER TABLE "products" ADD "currency" varchar(255)
64
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120402080614')
65
+  (76.9ms) commit transaction
66
+  (0.4ms) select sqlite_version(*)
67
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
68
+  (0.0ms) PRAGMA index_list("products")