jipiboily / spree_multi_lingual

Spree multi-lingual is a plugin to make multi locale store with Spree possible
BSD 3-Clause "New" or "Revised" License
49 stars 56 forks source link

error in migrations #33

Open ghost opened 11 years ago

ghost commented 11 years ago

I thought it was solved but running again the migrations on a brand new sample db leads to other errors when migrating products ... I also mentioned this issue to Spree gem (radar) as it could be a Spree issue ... 'on_demand' option being modified recently ..

as there is no uninstall process , it's quite a little bit messay to go back to initial Spree samples state ..

need to remove multilingual models decorators... need to comment multilingual initializer need to comment gem multilingual globalize3 in Gemfile run bundle install run bundle exec rake db:bootstrap to get a brand new sample data db THEN need to uncomment gem multilingual globalize3 in Gemfile run bundle install need to uncomment multilingual initializer need to add multilingual models decorators back run rails g spree_multi_lingual:install

then again ... here is the error

== MigrateDataForProducts: migrating ========================================= rake aborted! An error has occurred, all later migrations canceled: cannot set on_demand of product with variants

I 've done some debugging ( I'm not aware of Spree internals at all..) by running in the console w debugger

Spree::Product.find_each { |product| debugger; product.update_attributes!(product.untranslated_attributes, :without_protection => true) } this error happen on Spree::Product # 528469905 which seems to be the first product ( among the 16 in samples) to be a master with 3 variants

( no issues w previous products in the list: 107377505, 176895127, 187438981, 248786582, 302032070, 398400663, 459084718, 500501192, they are all master variants only... )

the error comes from trying to update: "on_demand"=>false on this product w variants...

product = Spree::Product.find(528469905) product.untranslated_attributes => { "name"=>"Spree Baseball Jersey", "description"=>"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla nonummy aliquet mi. Proin lacus. Ut placerat. Proin consequat, justo sit amet tempus consequat, elit est adipiscing odio, ut egestas pede eros in diam. Proin varius, lacus vitae suscipit varius, ipsum eros convallis nisi, sit amet sodales lectus pede non est. Duis augue. Suspendisse hendrerit pharetra metus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur nec pede. Quisque volutpat, neque ac porttitor sodales, sem lacus rutrum nulla, ullamcorper placerat ante tortor ac odio. Suspendisse vel libero. Nullam volutpat magna vel ligula. Suspendisse sit amet metus. Nunc quis massa. Nulla facilisi. In enim. In venenatis nisi id eros. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc sit amet felis sed lectus tincidunt egestas. Mauris nibh.", "meta_description"=>nil, "meta_keywords"=>nil, "permalink"=>"spree-baseball-jersey", "id"=>528469905, "available_on"=>Sun, 17 Feb 2013 19:25:06 CET +01:00, "deleted_at"=>nil, "tax_category_id"=>25484906, "shipping_category_id"=>nil, "count_on_hand"=>30, "created_at"=>Sun, 17 Feb 2013 19:25:06 CET +01:00, "updated_at"=>Sun, 17 Feb 2013 19:25:06 CET +01:00, "on_demand"=>false }

hope this helps ..Tested with Spree config config.track_inventory_levels=false and NO ERROR .... When using the Spree sample data , there are some products with variants, but by default track_inventory_levels is 'true'... as I raised this issue with Spree ge, I don't know if it has any impact on your gem, or if it's only related to Spree sample data....

======= debugging in console ========== (rdb:1) product.id 528469905 (rdb:1) product Spree::Product::Translation Load (0.9ms) SELECT spree_product_translations.* FROM spree_product_translations WHERE spree_product_translations.spree_product_id = 528469905 Spree::Product::Translation Load (0.8ms) SELECT spree_product_translations.* FROM spree_product_translations WHERE spree_product_translations.spree_product_id = 528469905 AND spree_product_translations.locale = 'en' LIMIT 1

<Spree::Product id: 528469905, name: nil, description: nil, available_on: "2013-02-17 17:26:03", deleted_at: nil, permalink: nil, meta_description: nil, meta_keywords: nil, tax_category_id: 25484906, shipping_category_id: nil, count_on_hand: 30, created_at: "2013-02-17 17:26:03", updated_at: "2013-02-17 17:26:03", on_demand: false>

(rdb:1) c (0.4ms) BEGIN (0.9ms) SELECT COUNT(*) FROM spree_variants WHERE spree_variants.product_id = 528469905 AND spree_variants.is_master = 0 AND spree_variants.deleted_at IS NULL (0.3ms) ROLLBACK RuntimeError: cannot set on_demand of product with variants