Guest User

Untitled

a guest
May 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. class CreateCustomers < ActiveRecord::Migration
  2. def self.up
  3. create_table :customers do |t|
  4. t.string :firstname
  5. t.string :lastname
  6. t.string :address1
  7. t.string :address2
  8. t.string :city
  9. t.integer :state
  10. t.integer :zipcode
  11. t.string :phone_number
  12. t.string :email
  13. t.string :alternative_phonenumber
  14.  
  15. t.timestamps
  16. end
  17. end
  18.  
  19. def self.down
  20. drop_table :customers
  21. end
  22. end
  23.  
  24.  
  25. class CreatePriorities < ActiveRecord::Migration
  26. def self.up
  27. create_table :priorities do |t|
  28. t.column "name", :string, :limit => 60
  29. t.column "digit", :string, :limit => 10
  30. end
  31.  
  32. Priority.create([
  33. { :name => 'high', :digit => 1},
  34. { :name => 'low', :digit => 2},
  35. { :name => 'medium', :digit => 3 },
  36. { :name => 'emergency', :digit => 4 }
  37. ])
  38. end
  39.  
  40. def self.down
  41. drop_table :priorities
  42. end
  43. end
  44.  
  45. class CreatePriorities < ActiveRecord::Migration
  46. def self.up
  47. create_table :priorities do |t|
  48. t.column "name", :string, :limit => 60
  49. t.column "digit", :string, :limit => 10
  50. end
  51.  
  52. Priority.create([
  53. { :name => 'high', :digit => 1},
  54. { :name => 'low', :digit => 2},
  55. { :name => 'medium', :digit => 3 },
  56. { :name => 'emergency', :digit => 4 }
  57. ])
  58. end
  59.  
  60. def self.down
  61. drop_table :priorities
  62. end
  63. end
  64.  
  65. class CreateShippings < ActiveRecord::Migration
  66. def self.up
  67. create_table :shippings do |t|
  68. t.column "name", :string, :limit => 40
  69. end
  70. ['Ground', 'Air', '3-day UPS', '3-Day Fedex', 'Next-Day UPS', ].each do |shipping|
  71. Shipping.create( :name => shipping )
  72. end
  73. end
  74.  
  75. def self.down
  76. drop_table :shippings
  77. end
  78. end
  79.  
  80. class CreateStatuses < ActiveRecord::Migration
  81. def self.up
  82. create_table :statuses do |t|
  83. t.column "name", :string, :limit => 15
  84. end
  85. ['Pending', 'Open', 'Contacted', 'Closed', 'Recieved', 'Ordered', 'Shipped', 'Approved' ].each do |status|
  86. Status.create( :name => status )
  87. end
  88. end
  89.  
  90. def self.down
  91. drop_table :statuses
  92. end
  93. end
Add Comment
Please, Sign In to add comment