Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Gordon Potter's Profile

GitHub User: GordonPotter

Comments by Gordon Potter

Avatar

To be more clear, what happens when you have a database that looks like this after several changes to the model:

database
Row id=1 name="Record 1", properties="foo"=>"...", "bar"=>"..."
Row id=2 name="Record 2", properties="foo"=>"...", "bar"=>"..."
Row id=3 name="Record 3", properties="foo"=>"...", "bar"=>"...", "baz"=>"..."
Row id=4 name="Record 4", properties="foo"=>"...", "bar"=>"...", "baz"=>"..."
Row id=5 name="Record 5", properties="foo"=>"...", "bar"=>"...", "baz"=>"...", "another_prop" => "..."
Row id=6 name="Record 6", properties="foo"=>"..."
Avatar

Does anybody know what implications there are as the keys change within an hstore column over time? Are migrations needed to make the keys consistent in the hstore column?

For example:

initial model class created with hstore column with keys:

:foo :bar

data added to database

one row/record has
"foo"=>"blah", "bar"=>"blah blah"
...
later changes made to model class new key added to hstore column
:baz

more data added to database
...
second row/record has
"foo"=>"blah", "bar"=>"blah blah", "baz"=>"blah blah blah"

Do I have to go back and make sure that the first record has an empty :baz property?

What about the removal of keys? What happens if I remove :foo from my model?