small medium large xlarge

12 May 2010, 13:39
LuisRuby (4 posts)

Hi friends! I am building an application using Postgre and I need to insert a lot of data from a spreadsheet into the database. I just built a big sql script but I found problems with duplicate values for some columns. It would be great if I could define some columns as “UNIQUE” in the migration model, so the Postgre would build those columns with this constraint. The book Agile Web 3rd Edition isn’t clear how to do this. Could someone help me? Thank you very much!

16 May 2010, 19:37
LuisRuby (4 posts)

Hmmmm, OK. It’s a newbie question. It’s for my last job for the university. Will anyone give me a help? Thanks!

17 May 2010, 04:23
Dave Thomas (396 posts)

The following adds a unique constraint to the @number@ column in the @orders@ table:

  add_index :orders, :number, :unique => false
You must be logged in to comment