i working on spreecommerce 3.0.2 app on rails 4.2
spree defines index on spree_shipping_rates table (taken schema.rb file):
add_index "spree_shipping_rates", ["shipment_id", "shipping_method_id"], name:     "spree_shipping_rates_join_index", unique: true, using: :btree   however, when spree_shipping_rates record destroyed, appears index entry still persists following error when creating the same record again:
pg::uniqueviolation: error:  duplicate key value violates unique constraint "spree_shipping_rates_join_index" detail:  key (shipment_id, shipping_method_id)=(3, 3) exists.   my questions how can make sure associated unique index removed when spree_shipping_rates record destroyed?
some context:
in spree, when user checking out , enters shipping , billing address , saves, new shipment order created , existing shipments destroyed.
if states[:delivery]     before_transition to: :delivery, do: :create_proposed_shipments     .     . end      def create_proposed_shipments   adjustments.shipping.delete_all   shipments.destroy_all   self.shipments = spree::stock::coordinator.new(self).shipments end     has_many :shipping_rates, -> { order('cost asc') }, dependent: :delete_all   as can see, associated shipping rates "deleted" when order's shipments destroyed.
does :delete_all in above code block not remove indexes? should :destroy?
 
 
  
Comments
Post a Comment