I have a table in my schema that does not have an auto generated ID primary key because I deactivated that option when creating it. Is there a way to put a new column ID that is auto incremented in my table?
if you don't want to Add new migration, also if there is not much more data which is most useful, than rails Also provide functionality to DOWN Migration.
rake db:migrate:down VERSION=20190204205537
'20190204205537' this should be your migration version
it will 'DOWN' your migration, than you can edit it, i mean remove the PRIMARY KEY false. and simply run
rake db:migrate
I Hope this may help to you. Thank you.
Yes, generate a migration with primary_key:
rails g migration add_id_to_my_tables id:primary_key
That will produce a change with add_column:
def change
add_column :my_tables, :id, :primary_key
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With