When Admin writes an Article data is stored like this:
Now we decide to get rid of Admin model and just have User model. We create a migration to change User records by removing _type attribute.
But what about our Article records? We need to update them too.
Otherwise we will get uninitialized constant Admin when trying to load articles with those relations.
Finally we decided to consolidate Company and User models and no longer use polymorphic relationship to author from Article. With Mongoid we can manually specify IDs during creation so we do not need to change the author_id. Here is the migration:
If we were not able to manually specify User.id to be the same as Company.id we would need to this: