Ruby/Rails - Active Record Db Migration to MySQL - timestamp type?

后端 未结 1 535
时光说笑
时光说笑 2021-01-22 17:26

I am using Redmine and when I run a rake db migration the database gets created in mysql ok. My problem is that the date field is wrong. I want it to be a mysql timestam

相关标签:
1条回答
  • 2021-01-22 17:54

    You can always insert a column with a custom type if you want. The symbol names are automatically converted into whatever ActiveRecord defines, but if you use a plain string it goes in as-is:

    t.column :ar_timestamp, :timestamp
    t.column :mysql_timestamp, 'timestamp'
    

    What you get is ar_timestamp being the usual DATETIME type where mysql_timestamp is defined as TIMESTAMP.

    0 讨论(0)
提交回复
热议问题