質問

I am learning Ruby and Sequel, and trying to make some table.

I want to save my time value as in UTC in PostgreSQL database. So I made a table with

db.create_table :TestTable1 do
    Timestamp   :field1
end

but I got

field1 | timestamp without time zone |           | plain    | 

I want my value in database to have strict basis. So I want to force everything in UTC. I think there should be a way to make TIMESTAMP WITH TIME ZONE column. How can I do this?

役に立ちましたか?

解決

When creating the table, you can specify specific types:

db.create_table :TestTable1 do
  column :field1, 'timestamp with time zone'
end

You probably want to use Sequel.default_timezone = :utc as well, but that doesn't affect how times are actually stored in the database.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top