Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backfill line items migration can cause NumericValueOutOfRange on existing shops #5893

Closed
javereec opened this issue Jan 15, 2015 · 1 comment

Comments

@javereec
Copy link

I encountered this issue when upgrading from 2-3-stable to 2-4-stable.

Steps to reproduce:

  1. Install spree v2.3.x
  2. Create an order with a line value > 10^6
  3. Install spree v2.4.x, upgrade your shop and install new migration
  4. Run bundle exec rake db:migrate

I was able to migrate when I updated the quantity of some of the lines (sadly those were no real orders ;-))

Not sure what you can do about this, but letting you know.

== 20141219093029 BackfillLineItemPreTaxAmount: migrating =====================
-- execute("      UPDATE spree_line_items\n      SET pre_tax_amount = ((price * quantity) + promo_total) - included_tax_total\n      WHERE pre_tax_amount IS NULL;\n")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::NumericValueOutOfRange: ERROR:  numeric field overflow
DETAIL:  A field with precision 8, scale 2 must round to an absolute value less than 10^6.
:       UPDATE spree_line_items
      SET pre_tax_amount = ((price * quantity) + promo_total) - included_tax_total
      WHERE pre_tax_amount IS NULL;
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `async_exec'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activesupport-4.1.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:656:in `block in method_missing'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:628:in `block in say_with_time'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:628:in `say_with_time'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:648:in `method_missing'
/Users/myuser/Development/theshop/db/migrate/20141219093029_backfill_line_item_pre_tax_amount.spree.rb:5:in `change'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:602:in `exec_migration'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:586:in `block (2 levels) in migrate'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:585:in `block in migrate'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:584:in `migrate'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:759:in `migrate'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:1044:in `block in ddl_transaction'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/transactions.rb:208:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:1044:in `ddl_transaction'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:959:in `block in migrate'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:955:in `each'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:955:in `migrate'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:814:in `up'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/migration.rb:792:in `migrate'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/gems/activerecord-4.1.9/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/bin/ruby_executable_hooks:15:in `eval'
/Users/myuser/.rvm/gems/ruby-2.1.2@theshop/bin/ruby_executable_hooks:15:in `<main>'
@texpert
Copy link

texpert commented Sep 28, 2020

I have encountered this error as well, manually fixed it adding to the BackfillLineItemPreTaxAmount migration this line:

change_column :spree_line_items, :pre_tax_amount, :decimal, precision: 10, scale: 2, default: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants