Andrew Paul Simmons
Andrew Paul Simmons

Reputation: 4513

With Ruby on Rails, how do I create an ActiveRecord migration with a default value for datetime of January 1st, 2004

Here is my migration

class AddUpdateStartedAtToToUserMappings < ActiveRecord::Migration
   def change
     add_column :user_mappings, :update_started_at, :datetime, default: DateTime.now
   end 
end

I want the default to be January 1st, 2004 not DateTime.now

How do I do this?

Upvotes: 1

Views: 34

Answers (1)

Mihail Petkov
Mihail Petkov

Reputation: 1545

change:

DateTime.now

to

DateTime.new(2004, 1, 1)

Upvotes: 4

Related Questions