Change column default value in ActiveRecord

Use change_column_default, which accepts three arguments (the table name, the column name, and the new default value).

See also

API Documentation (v7.0.3)

Change the default value for table column with migration

PS

It is never too late for TIL (Today I Learned) type of blog posts. I hesitated making these types of posts because I can save the StackOverflow URL anyway. Unfortunately, now I have 12 years worth of StackOverflow URLs saved in my computer and I have just started to curate.

You’re welcome.

Comments

Leave a comment