This project is archived and is in readonly mode.

#1906 ✓invalid

Problem with adding id in migration

Reported by klew | February 7th, 2009 @ 04:50 PM | in 2.x

I use Rails 2.2.2 with sqlite3 3.5.6 under Vista.

Firstly I created a table without id, but later I found it wasn't good idea and I wanted to add id column with migration:

class AddIdToPersonRelation < ActiveRecord::Migration def self.up

add_column :person_relations, :id, :integer


def self.down

remove_column :person_relations, :id

end end

Then I run migration: rake db:migrate And I found that Rails didn't set id field as primary key, so when I added something to the table, id was set to nil. It wasn't what I expected.

Then I run: rake db:schema:load And it created all tables again and person_relations table had correct primary key.

I think that both methods (db:migrate and db:schema:load) should give the same results.

Maybe I am wrong (I am new in ruby and rails).

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket