我正在尝试在 Sequel 中创建一个默认值:
create_table(:my_table) do
primary_key :id
# ..........
Timestamp :created_at, default: "now()"
运行迁移后,它会生成一个包含此列定义的表:
--........
created_at timestamp without time zone DEFAULT '2017-10-28 12:26:00.129157'::timestamp without time zone,
但我想要的是在插入新值时设置的值“now()”。
最佳答案
我知道不久前有人问过这个问题,但我遇到了一个类似的问题,我使用 Sequal.lit
时间戳:created_at,默认:Sequel.lit("now()")
关于ruby - 默认 : "now()" in Sequel generates literal embedded into the defenitiion of a table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46986793/