Consider the table creation script below:
create_table :foo do |t|
t.datetime :starts_at, :null => false
end
Is it's possible to set the default value as the current time?
I am trying to find a DB independent equivalent in rails for the SQL column definitions given below:
Oracle Syntax
start_at DATE DEFAULT SYSDATE()
MySQL Syntax
start_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
OR
start_at DATETIME DEFAULT NOW()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…