Say that I have many blogs, and each blog has_many
posts. These are stored in 2 tables ("blogs" and "posts"). Is it possible to add an additional column (e.g. scoped_id) to the blog table which stores an ID, scoped by the blog.
Example
Blog: 1
- Posts
- id: 1, scoped_id: 1
- id: 2, scoped_id: 2
- id: 3, scoped_id: 3
Blog: 2
- Posts
- id: 4, scoped_id: 1
- id: 5, scoped_id: 2
- id: 6, scoped_id: 3
I know that counter_cache can keep track of the number of posts scoped by the parent blog. However, I don't want the scoped_id
to decrement if a post is destroyed.