Make DSM timestamp columns NOT NULL

This commit is contained in:
Rohan Mitchell
2014-07-04 12:02:15 +10:00
parent ae0392b383
commit 8b67fc4d61
2 changed files with 20 additions and 4 deletions

View File

@@ -1,7 +1,23 @@
class AddFieldsToDistributorsShippingMethods < ActiveRecord::Migration
def change
class DistributorShippingMethod < ActiveRecord::Base
self.table_name = "distributors_shipping_methods"
end
def up
add_column :distributors_shipping_methods, :id, :primary_key
add_column :distributors_shipping_methods, :created_at, :datetime
add_column :distributors_shipping_methods, :updated_at, :datetime
DistributorShippingMethod.reset_column_information
DistributorShippingMethod.update_all created_at: Time.now, updated_at: Time.now
change_column :distributors_shipping_methods, :created_at, :datetime, null: false
change_column :distributors_shipping_methods, :updated_at, :datetime, null: false
end
def down
remove_column :distributors_shipping_methods, :id
remove_column :distributors_shipping_methods, :created_at
remove_column :distributors_shipping_methods, :updated_at
end
end

View File

@@ -166,8 +166,8 @@ ActiveRecord::Schema.define(:version => 20140702053145) do
create_table "distributors_shipping_methods", :force => true do |t|
t.integer "distributor_id"
t.integer "shipping_method_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "distributors_shipping_methods", ["distributor_id"], :name => "index_distributors_shipping_methods_on_distributor_id"
@@ -562,9 +562,9 @@ ActiveRecord::Schema.define(:version => 20140702053145) do
t.string "email"
t.text "special_instructions"
t.integer "distributor_id"
t.integer "order_cycle_id"
t.string "currency"
t.string "last_ip_address"
t.integer "order_cycle_id"
t.integer "cart_id"
end