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


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


remove primary key in mysql

how to add a primary key to a table in rails



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.