madrahimov

Online Order new columns

Mar 22nd, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.13 KB | None | 0 0
  1. class AddOnlineOrderNewColumns < ActiveRecord::Migration
  2.   def up
  3.     add_column "bill.online_orders", :is_payed, :boolean, null: false, default: false
  4.     add_column "bill.online_orders", :payment_system_id, :uuid, null: true
  5.     add_column "bill.online_orders", :payment_system_class, :string, null: true
  6.     add_column "bill.online_orders", :payed_amount, :decimal, precision: 20, scale: 4, default: 0, null: false
  7.     add_column "bill.online_orders", :is_delivery_in_cash, :boolean, null: false, default: false
  8.     add_column "restaurant.restaurant_settings", :is_delivery_in_cash, :boolean, null: false, default: true
  9.  
  10.     add_column "bill.bills", :delivery_amount, :decimal, precision: 20, scale: 4, default: 0, null: false
  11.  
  12.  
  13.     Restaurant.all.each do |r|
  14.       pay_type = LocalRestaurant::PayType.new
  15.       pay_type.restaurant_id = r.id
  16.       pay_type.name = 'online'
  17.       pay_type.save
  18.     end
  19.   end
  20.  
  21.   def down
  22.     remove_column "bill.online_orders", :is_payed, :payment_system_id, :payment_system_class, :payed_amount, :is_delivery_in_cash
  23.     remove_column "restaurant.restaurant_settings", :is_delivery_in_cash
  24.   end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment