[Ror-es] problema con migraciones y primary key

Ruben Colina ruben.colina at gmail.com
Wed Jul 4 01:26:16 GMT 2007


>En principio, no aparece ninguna forma directa usando create_table, sin
>embargo tienes 2 opciones:
>Generar el create "a mano", usando execute y la sql
>Dejarlo como dijimos y añadirle un índice único usando:
> add_index(:establecimientos, :archivo, :unique => true)

gracias Moises, me gusto la segunda forma pero consegui una forma que me
parece un poco mejor, lo que hice es lo siguiente y me funciono
perfectamente:
class CreateEstablecimientos < ActiveRecord::Migration
  def self.up
    create_table :establecimientos, :id => false do |t|
           .
           .
           .
    end
           execute "ALTER TABLE establecimientos ADD PRIMARY
KEY(\`archivo\`)"
    end

  def self.down
    drop_table :establecimientos
  end
end

GRACIAS por la ayuda!!!

-- 
Ruben Colina
Debian GNU/Linux User

"Those who are enamored of practice without theory are like a pilot who goes
into a ship without rudder or compass and never has any certainty where he
is going. Practice should always be based on a sound knowledge of theory."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.simplelogica.net/pipermail/ror-es/attachments/20070703/2c1cac3d/attachment.htm 


More information about the Ror-es mailing list