Rails - the specified column is already in the prod database - How to add a migration that adds a default Val

I have a column version_num, in one of my tables, I noticed that by default the value does not fill up to 1.

Given that I already have a field in production, how can you add a wrapper that just adds a default value to the field?

thank

+3
source share
1 answer

use the method change_column:

change_column :some_table, :column, :type, :default => 'foo'

See also: http://api.rubyonrails.org/classes/ActiveRecord/Migration.html

+6
source

Source: https://habr.com/ru/post/1784224/


All Articles