I have a table(Users). In one of its columns(configs) i added a default value ("A"=>0) through a migration. Now all the new users i create have default value of A but the old users don't. I want to backfill the default value of A for the old users using migration. How do I do that?
given:
t.jsonb "configs", default: {"B"=>7, "C"=>10, "D"=>10}
This is my existing column. Here B, C and D have different values for different Users. I want to make it into
t.jsonb "configs", default: {"B"=>7, "C"=>10, "D"=>10, "A"=>0}
where the values of B, C and D stays the same for all Users but just the default value of "A" gets added to the existing json in the column.
rails - 4.2.11 db - postgres
I have gone through some documentations but couldn't find a comprehensive answer. Any help is appreciated.