Sha256: 2596dde6f1277a73b66ff763be92c018a6d5a4a26cfde818c04ada69fe116301

Contents?: true

Size: 1.06 KB

Versions: 20

Compression:

Stored size: 1.06 KB

Contents

class RefactorOrderState < ActiveRecord::Migration
  def self.up
    change_table :orders do |t|
      t.rename :checkout_state, :state
      t.boolean :checkout_complete
    end
    
    # migrate any existing orders
    execute "update orders set state = 'in_progress' WHERE status = 1"
    execute "update orders set state = 'authorized' WHERE status = 2"
    execute "update orders set state = 'captured' WHERE status = 3"
    execute "update orders set state = 'canceled' WHERE status = 4"
    execute "update orders set state = 'returned' WHERE status = 5"
    execute "update orders set state = 'shipped' WHERE status = 6"
    execute "update orders set state = 'paid' WHERE status = 7"
    execute "update orders set state = 'pending_payment' WHERE status = 8"
    execute "update orders set state = 'in_progress' WHERE status = 9"
    
    change_table :orders do |t|
      t.remove :status
    end
    
  end

  def self.down
    change_table :orders do |t|
      t.rename :state, :checkout_state
      t.remove :checkout_complete
      t.integer :status
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
kdmny-spree-0.0.1 db/migrate/20080904150723_refactor_order_state.rb
spree-enriquez-0.9.4 db/migrate/20080904150723_refactor_order_state.rb
spree-0.9.4 db/migrate/20080904150723_refactor_order_state.rb
spree-0.9.3 db/migrate/20080904150723_refactor_order_state.rb
spree-0.9.2 db/migrate/20080904150723_refactor_order_state.rb
spree-0.9.1 db/migrate/20080904150723_refactor_order_state.rb
spree-0.9.0 db/migrate/20080904150723_refactor_order_state.rb
spree-0.8.4 db/migrate/20080904150723_refactor_order_state.rb
spree-0.8.5 db/migrate/20080904150723_refactor_order_state.rb
spree-0.4.0 db/migrate/20080904150723_refactor_order_state.rb
spree-0.4.1 db/migrate/20080904150723_refactor_order_state.rb
spree-0.5.0 db/migrate/20080904150723_refactor_order_state.rb
spree-0.6.0 db/migrate/20080904150723_refactor_order_state.rb
spree-0.5.1 db/migrate/20080904150723_refactor_order_state.rb
spree-0.7.1 db/migrate/20080904150723_refactor_order_state.rb
spree-0.7.0 db/migrate/20080904150723_refactor_order_state.rb
spree-0.8.0 db/migrate/20080904150723_refactor_order_state.rb
spree-0.8.1 db/migrate/20080904150723_refactor_order_state.rb
spree-0.8.2 db/migrate/20080904150723_refactor_order_state.rb
spree-0.8.3 db/migrate/20080904150723_refactor_order_state.rb