Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you write a rails migration to remove the :id => false option in the schema.rb?

How do you write a rails migration to remove the :id => false option in the schema.rb? It doesn't seem like this is a method in change_table.

like image 757
TKH Avatar asked Oct 20 '11 18:10

TKH


People also ask

How do you destroy migration in rails?

【Ruby on Rails】 When you want to delete a migration file you made, you can choose version and delete it. You don't need to execute rails db:rollback many times!

What is null false in rails migration?

The null: false parameter means this column does not allow NULL values. The default: false tells us this column will default to false whenever a value isn't specified. This is nice because we can guarantee this field will always be either true or false now. It can't be null because the database prevents it.

How do I run a specific migration in rails?

To run a specific migration up or down, use db:migrate:up or db:migrate:down . The version number in the above commands is the numeric prefix in the migration's filename. For example, to migrate to the migration 20160515085959_add_name_to_users. rb , you would use 20160515085959 as the version number.

How do I rollback a particular migration in rails?

To check for status, run rails db:migrate:status . Then you'll have a good view of the migrations you want to remove. Then, run rails db:rollback to revert the changes one by one. After doing so, you can check the status again to be fully confident.


1 Answers

Try this

add_column :models, :id, :primary_key
like image 59
Segfault Avatar answered Oct 20 '22 03:10

Segfault