Sha256: 18f8f5a14ee888e47e35535bc91905ca75f73b047764ae5f0fe44c640c9c8c0a
Contents?: true
Size: 659 Bytes
Versions: 8
Compression:
Stored size: 659 Bytes
Contents
# This migration comes from spree (originally 20170315152755) class AddUniqueIndexOnNumberToSpreeOrders < ActiveRecord::Migration[5.0] def change unless index_exists?(:spree_orders, :number, unique: true) numbers = Spree::Order.group(:number).having('sum(1) > 1').pluck(:number) orders = Spree::Order.where(number: numbers) orders.find_each do |order| order.number = order.class.number_generator.method(:generate_permalink).call(order.class) order.save end remove_index :spree_orders, :number if index_exists?(:spree_orders, :number) add_index :spree_orders, :number, unique: true end end end
Version data entries
8 entries across 8 versions & 2 rubygems