"how to change primary key in rails migration file?" Code Answer

3

you could execute arbitrary sql in your migration:

execute "alter table `products` drop primary key"

and then add the new column:

add_column :products, :id, :primary_key

see:

remove primary key in mysql

how to add a primary key to a table in rails

http://thinkwhere.wordpress.com/2009/05/09/adding-a-primary-key-id-to-table-in-rails/

http://api.rubyonrails.org/classes/activerecord/migration.html

By Peter Giacomo Lombardo on August 30 2022

Answers related to “how to change primary key in rails migration file?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.