Ruby on Rails Tuesday, October 28, 2014

Hi Jason,

We are all running the same version of Postgres: psql (PostgreSQL) 9.3.4 and below is how the migration file looks like:

class CreateContacts < ActiveRecord::Migration
  def change
    create_table :contacts do |t|
      t.string :name
      t.string :phone_number
      t.string :email
 
      t.timestamps
    end
  end
end

The problem we're seeing is that when some people run the migration they get t.datetime while some others get t.timestamp. As far as rails goes, rails doesn't care which is which as explained in the link above, but what's causing this difference?

On Tuesday, October 28, 2014 4:07:14 PM UTC+3, Jason FB wrote:


are you sure you guys are running the same version of Postgres? 

What does your actual migration file look like?

-Jason


On Oct 28, 2014, at 7:51 AM, bertly_the_coder <muc...@gmail.com> wrote:

Hi group,

We're working as a team of programmers and for most of us, when we run rake db:migrate, we get our datetime columns to show up with the datetime datatype in the schema.rb file, but for others, when they run rake db:migrate, these columns show up as timestamp in the schema.rb file.(See example below). We're all on Ruby 2.1.0 and Rails 4.0.9 and using Postgres for our DB. I know that as far as the postgres goes, it treats both timestamp and datetime the same, but is there anyway to fix this? Is there a setting that needs to be changed?

example:
create_table "contacts", force: true do |t|
    t.string   "name"
    t.string   "phone_number"
    t.string   "email"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "user_id"
    t.string   "uuid"
    t.text     "log"
  end
VS
create_table "contacts", force: true do |t|
    t.string   "name"
    t.string   "phone_number"
    t.string   "email"
    t.timestamp "created_at"
    t.timestamp "updated_at"
    t.integer  "user_id"
    t.string   "uuid"
    t.text     "log"
  end
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/032af631-cff0-4bf0-9237-85017f2f94d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

----

Jason Fleetwood-Boldt

All material © Jason Fleetwood-Boldt 2014. Public conversations may be turned into blog posts (original poster information will be made anonymous). Email ja...@datatravels.com with questions/concerns about this.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7652e251-b539-4bb7-9342-301312978248%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment