This change adds a root_stack_id column to the resource
record to allow a subsequent change enforce
max_resources_per_stack with a single query instead of the
many it currently requires.
This change includes the following:
- Data migration to add the resource.root_stack_id column
and populate all existing resources with their calculated
root stack
- Make new resources aquire and set their root_stack_id on
store or update.
- StackResource._validate_nested_resources use the stored
root_stack_id resulting in a ~15% performance improvement
for the creation time of a test stack containing 40 nested
stacks.
Change-Id: I2b00285514235834131222012408d2b5b2b37d30
Partial-Bug: 1489548