Echa un vistazo a esta respuesta. Intente execute "ALTER TABLE shareholders ADD PRIMARY KEY (uid);"
sin especificar el parámetro primary_key en el bloque create_table.
Le sugiero que escriba su migración de esta manera (para que pueda retroceder normalmente):
class CreateShareholders < ActiveRecord::Migration
def up
create_table :shareholders, id: false do |t|
t.integer :uid, limit: 8
t.string :name
t.integer :shares
t.timestamps
end
execute "ALTER TABLE shareholders ADD PRIMARY KEY (uid);"
end
def down
drop_table :shareholders
end
end
UPD: Hay una forma natural (que se encuentra aquí), pero solo con el tipo int4:
class CreateShareholders < ActiveRecord::Migration
def change
create_table :shareholders, id: false do |t|
t.primary_key :uid
t.string :name
t.integer :shares
t.timestamps
end
end
end