Skip to content

Rails 6 migrations: t.timestamps adds precision: 6 #37031

@6temes

Description

@6temes

Steps to reproduce

When creating a new migration in Rails 6:

class CreateProducts < ActiveRecord::Migration[6.0]  
  def change    
    create_table :products do |t|      
      t.string :name
      t.timestamps    
    end 
  end
end

A new option, precision is created:

    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false

The change was introduced in this PR:

#34970

Following this discussion:

#34956 (comment)

It seems that, initially, the goal was to solve a problem with MySQL version updates, but for some reason, the subsequent PR targetted all Databases, including Postgres.

My question is: Is there any good reason to explicitly specify the precision of the timestamps by default in Postgres? If so, would it be possible to document the reasons somewhere?

System configuration

Rails version: 6.0
Ruby version: 2.6.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions