In response to ticket #6424 I have included a patch to implement foreign key references as suggested by esad. Basically, this patch allows you to do the following:
parent table
robinson:
id: 1
name: Robinson
child table
joe_robinson:
id: 1
family_id: <%= @robinson['id'] %>
name: Joe Robinson
There is of course the requirement that parent tables be listed first when creating fixtures.
In addition, there is the ability to reference parent records via the new auto_increment, push_parent, parent, and pop_parent methods. The method auto_increment, as expected, keeps a running counter. The parent methods use the counter and ancestor stack to keep track of parents. Here is an example:
--- !!omap
- grandpa_joe_robinson:
id: <%= auto_increment %>
family_id: <%= @robinson['id'] %>
name: Joe Robinson
<% push_parent %>
- father_joe_robinson:
id: <%= auto_increment %>
family_id: <%= @robinson['id'] %>
parent_id: <%= parent %>
name: Joe Robinson Jr.
<% push_parent %>
- grandson_joe_robinson:
id: <%= auto_increment %>
family_id: <%= @robinson['id'] %>
parent_id: <%= parent %>
name: Joe Robinson III
<% pop_parent %>
- uncle_john_robinson:
id: <%= auto_increment %>
family_id: <%= @robinson['id'] %>
parent_id: <%= parent %>
name: John Robinson
The auto_increment methods can be used anywhere, but the parent methods are only practical using omap. For this reason, I had to include in the patch a fix for omap, which is currently broken as mentioned in #2665.